Skip to content

Commit 566c448

Browse files
committed
Merge branch 'master-4.0' into merge-c9206c-to-master-4.0
Conflicts: CHANGELOG.md version.txt
2 parents c9206cc + 0637922 commit 566c448

28 files changed

Lines changed: 927 additions & 57 deletions

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
## 3.8.0 (YYYY-MM-DD)
1+
4.0.0-BETA3 (YYYY-MM-DD)
2+
3+
### Internal
4+
5+
* Upgraded to Realm Sync 2.0.0-rc16.
6+
* Upgraded to Realm Core 3.0.0-rc5.
7+
8+
## 4.0.0-BETA2 (2017-07-27)
9+
10+
### Bug Fixes
11+
12+
* [ObjectServer] Realm no longer throws a native “unsupported instruction” exception in some cases when opening a synced Realm asynchronously (https://github.com/realm/realm-object-store/issues/502).
13+
14+
## 4.0.0-BETA1 (2017-07-13)
215

316
### Breaking Changes
417

18+
* [ObjectServer] Updated protocol version to 19 which is only compatible with ROS > 2.0.0.
19+
520
### Deprecated
621

722
### Enhancements
823

24+
* Added `static RealmObject.getRealm(RealmModel)`, `RealmObject.getRealm()` and `DynamicRealmObject.getDynamicRealm()` (#4720).
25+
926
### Bug Fixes
1027

1128
### Internal
1229

30+
* Upgraded to Realm Sync 2.0.0-rc12.
31+
* Upgraded to Realm Core 3.0.0-rc3.
32+
1333

1434
## 3.7.0 (2017-09-01)
1535

dependencies.list

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Realm Sync Core release used by Realm Java
22
# https://github.com/realm/realm-sync/releases
3-
REALM_SYNC_VERSION=1.10.8
4-
REALM_SYNC_SHA256=ee47cbce2bcbd105a27d0a6b64316f8ffcb1a090e697c8025d738ef5917de408
3+
REALM_SYNC_VERSION=2.0.0-rc16
4+
REALM_SYNC_SHA256=c20c4e7333f01a3a4ea350cb20b9b7feba95ad4e52d612368b6187b72d518aa1
55

66
# Object Server Release used by Integration tests
7-
# `realm` is stable releases, `realm-testing` is developer builds.
8-
# https://packagecloud.io/realm/realm?filter=debs
9-
# https://packagecloud.io/realm/realm-testing?filter=debs
7+
# Stable releases: https://packagecloud.io/realm/realm?filter=debs
8+
# Beta releases: https://packagecloud.io/realm/realm-beta?filter=debs
9+
# Developer builds: https://packagecloud.io/realm/realm-testing?filter=debs
1010
# /tools/sync_test_server/Dockerfile specify which repo (apt) we should
11-
# install/use between 'realm' and 'realm-testing', the version below should
11+
# install/use between 'realm', 'realm-beta' and 'realm-testing', the version below should
1212
# correspond to an existing version on the *specified* repo.
13-
REALM_OBJECT_SERVER_DE_VERSION=1.8.3-83
13+
REALM_OBJECT_SERVER_DE_VERSION=2.0.0-rc2-285

realm/realm-annotations-processor/src/test/resources/some/test/ConflictingFieldName.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public class ConflictingFieldName extends RealmObject {
2929
private String isCompleted;
3030
private String currentTableVersion;
3131

32-
public String getRealm() {
32+
public String getRealmString() {
3333
return realm;
3434
}
3535

36-
public void setRealm(String realm) {
36+
public void setRealmString(String realm) {
3737
this.realm = realm;
3838
}
3939

realm/realm-library/src/androidTest/java/io/realm/DynamicRealmObjectTests.java

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.support.test.runner.AndroidJUnit4;
2020

21+
import org.hamcrest.Matchers;
2122
import org.junit.After;
2223
import org.junit.Before;
2324
import org.junit.Rule;
@@ -56,6 +57,8 @@
5657
import static org.junit.Assert.assertFalse;
5758
import static org.junit.Assert.assertNotNull;
5859
import static org.junit.Assert.assertNull;
60+
import static org.junit.Assert.assertSame;
61+
import static org.junit.Assert.assertThat;
5962
import static org.junit.Assert.assertTrue;
6063
import static org.junit.Assert.fail;
6164

@@ -1158,7 +1161,11 @@ public void getFieldNames() {
11581161
AllJavaTypes.FIELD_DOUBLE, AllJavaTypes.FIELD_BOOLEAN, AllJavaTypes.FIELD_DATE,
11591162
AllJavaTypes.FIELD_BINARY, AllJavaTypes.FIELD_OBJECT, AllJavaTypes.FIELD_LIST};
11601163
String[] keys = dObjTyped.getFieldNames();
1161-
assertArrayEquals(expectedKeys, keys);
1164+
// After the stable ID support, primary key field will be inserted first before others. So even FIELD_STRING is
1165+
// the first defined field in the class, it will be inserted after FIELD_ID.
1166+
// See ObjectStore::add_initial_columns #if REALM_HAVE_SYNC_STABLE_IDS branch.
1167+
assertEquals(expectedKeys.length, keys.length);
1168+
assertThat(Arrays.asList(expectedKeys), Matchers.hasItems(keys));
11621169
}
11631170

11641171
@Test
@@ -1259,4 +1266,102 @@ public void testExceptionMessage() {
12591266
assertEquals("Illegal Argument: Field not found: nonExisting", e.getMessage());
12601267
}
12611268
}
1269+
1270+
@Test
1271+
public void getDynamicRealm() {
1272+
realm.beginTransaction();
1273+
realm.createObject(AllTypes.class);
1274+
realm.commitTransaction();
1275+
1276+
dynamicRealm.refresh();
1277+
final DynamicRealmObject object = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst();
1278+
1279+
assertSame(dynamicRealm, object.getDynamicRealm());
1280+
}
1281+
1282+
@Test
1283+
public void getRealm() {
1284+
realm.beginTransaction();
1285+
realm.createObject(AllTypes.class);
1286+
realm.commitTransaction();
1287+
1288+
dynamicRealm.refresh();
1289+
final DynamicRealmObject object = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst();
1290+
1291+
thrown.expect(IllegalStateException.class);
1292+
object.getRealm();
1293+
}
1294+
1295+
@Test
1296+
public void getRealm_closedObjectThrows() {
1297+
realm.beginTransaction();
1298+
realm.createObject(AllTypes.class);
1299+
realm.commitTransaction();
1300+
1301+
dynamicRealm.refresh();
1302+
final DynamicRealmObject object = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst();
1303+
dynamicRealm.close();
1304+
dynamicRealm = null;
1305+
1306+
try {
1307+
object.getDynamicRealm();
1308+
fail();
1309+
} catch (IllegalStateException e) {
1310+
assertEquals(BaseRealm.CLOSED_REALM_MESSAGE, e.getMessage());
1311+
}
1312+
}
1313+
1314+
@Test
1315+
public void getRealmConfiguration_deletedObjectThrows() {
1316+
realm.beginTransaction();
1317+
realm.createObject(AllTypes.class);
1318+
realm.commitTransaction();
1319+
1320+
dynamicRealm.refresh();
1321+
final DynamicRealmObject object = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst();
1322+
dynamicRealm.beginTransaction();
1323+
object.deleteFromRealm();
1324+
dynamicRealm.commitTransaction();
1325+
1326+
try {
1327+
object.getDynamicRealm();
1328+
fail();
1329+
} catch (IllegalStateException e) {
1330+
assertEquals(RealmObject.MSG_DELETED_OBJECT, e.getMessage());
1331+
}
1332+
}
1333+
1334+
@Test
1335+
public void getRealm_illegalThreadThrows() throws Throwable {
1336+
realm.beginTransaction();
1337+
realm.createObject(AllTypes.class);
1338+
realm.commitTransaction();
1339+
1340+
dynamicRealm.refresh();
1341+
final DynamicRealmObject object = dynamicRealm.where(AllTypes.CLASS_NAME).findFirst();
1342+
1343+
final CountDownLatch threadFinished = new CountDownLatch(1);
1344+
final AtomicReference<Throwable> throwable = new AtomicReference<>();
1345+
final Thread thread = new Thread(new Runnable() {
1346+
@Override
1347+
public void run() {
1348+
try {
1349+
object.getDynamicRealm();
1350+
fail();
1351+
} catch (Throwable t) {
1352+
throwable.set(t);
1353+
} finally {
1354+
threadFinished.countDown();
1355+
}
1356+
}
1357+
});
1358+
thread.start();
1359+
TestHelper.awaitOrFail(threadFinished);
1360+
1361+
final Throwable thrownInTheThread = throwable.get();
1362+
if (!(thrownInTheThread instanceof IllegalStateException)) {
1363+
throw thrownInTheThread;
1364+
}
1365+
assertEquals(BaseRealm.INCORRECT_THREAD_MESSAGE, thrownInTheThread.getMessage());
1366+
}
12621367
}

0 commit comments

Comments
 (0)