File tree Expand file tree Collapse file tree
androidTest/java/io/realm Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77### Bug fixes
88
99* Added version number to the native library, preventing ReLinker from accidentally loading old code (#3775 ).
10+ * ` Realm.getLocalInstanceCount(config) ` throwing NullPointerException if called after all Realms have been closed (#3791 ).
1011
1112## 2.2.0
1213
Original file line number Diff line number Diff line change @@ -3796,20 +3796,20 @@ public void run() {
37963796 @ Test
37973797 public void getLocalInstanceCount () {
37983798 final RealmConfiguration config = configFactory .createConfiguration ("localInstanceCount" );
3799- assertEquals (0 , Realm .getGlobalInstanceCount (config ));
3799+ assertEquals (0 , Realm .getLocalInstanceCount (config ));
38003800
38013801 // Open thread local Realm
38023802 Realm realm = Realm .getInstance (config );
3803- assertEquals (1 , Realm .getGlobalInstanceCount (config ));
3803+ assertEquals (1 , Realm .getLocalInstanceCount (config ));
38043804
38053805 // Open thread local DynamicRealm
38063806 DynamicRealm dynRealm = DynamicRealm .getInstance (config );
3807- assertEquals (2 , Realm .getGlobalInstanceCount (config ));
3807+ assertEquals (2 , Realm .getLocalInstanceCount (config ));
38083808
38093809 dynRealm .close ();
3810- assertEquals (1 , Realm .getGlobalInstanceCount (config ));
3810+ assertEquals (1 , Realm .getLocalInstanceCount (config ));
38113811 realm .close ();
3812- assertEquals (0 , Realm .getGlobalInstanceCount (config ));
3812+ assertEquals (0 , Realm .getLocalInstanceCount (config ));
38133813 }
38143814
38153815 @ Test
Original file line number Diff line number Diff line change @@ -402,7 +402,8 @@ static int getLocalThreadCount(RealmConfiguration configuration) {
402402 } else {
403403 int totalRefCount = 0 ;
404404 for (RealmCacheType type : RealmCacheType .values ()) {
405- totalRefCount += cache .refAndCountMap .get (type ).localCount .get ();
405+ Integer localCount = cache .refAndCountMap .get (type ).localCount .get ();
406+ totalRefCount += (localCount != null ) ? localCount : 0 ;
406407 }
407408 return totalRefCount ;
408409 }
You can’t perform that action at this time.
0 commit comments