Skip to content

Commit 703c48e

Browse files
committed
Merge branch 'master-4.0' into merge-c02607-to-master-4.0
Conflicts: dependencies.list
2 parents c026078 + 9e31381 commit 703c48e

28 files changed

Lines changed: 941 additions & 64 deletions

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
## 4.0.0-BETA2 (2017-07-27)
2+
3+
### Bug Fixes
4+
5+
* [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).
6+
7+
## 4.0.0-BETA1 (2017-07-13)
8+
9+
### Breaking Changes
10+
11+
* [ObjectServer] Updated protocol version to 19 which is only compatible with ROS > 2.0.0.
12+
13+
### Deprecated
14+
15+
### Enhancements
16+
17+
* Added `static RealmObject.getRealm(RealmModel)`, `RealmObject.getRealm()` and `DynamicRealmObject.getDynamicRealm()` (#4720).
18+
19+
### Bug Fixes
20+
21+
### Internal
22+
23+
* Upgraded to Realm Sync 2.0.0-rc12.
24+
* Upgraded to Realm Core 3.0.0-rc3.
25+
26+
### Credits
27+
28+
129
## 3.6.0 (YYYY-MM-DD)
230

331
### Breaking Changes

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.5
4-
REALM_SYNC_SHA256=c93caa9b0ff1391550ce6b68ab3822fea7e6ae921498a3ebf3a5e6b17c56fa9b
3+
REALM_SYNC_VERSION=2.0.0-rc12
4+
REALM_SYNC_SHA256=5f111903159ee2d74c5418560c72977e91a10e291e23e6a7d9999aa856858ca4
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)