realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

opening realm db with same SyncConfiguration but diffrent error handler throw IllegalArgumentException

Open idok595 opened this issue 9 years ago • 3 comments

when i am tring to re-open realm database that allready have been closed using "Realm.getInstanceAsync" with same data but diffrent ErrorHandler, i am getting this exception "Configurations cannot be different if used to open the same file", why it make no sense to force the user to keep the same ErrorHandler reffrenece and share it in diffrent places that want to open synced realm database, the ErrorHandler has no effect on the way of working with the realm database it is just a listener

realm version:3.5.0

idok595 avatar Jul 19 '17 13:07 idok595

If your error handler implements hashCode/equals then it wouldn't matter.

Zhuinden avatar Jul 19 '17 17:07 Zhuinden

@idok595 Why do you need a different error handler the 2nd time? The reasoning behind the current logic is that we see the SyncConfiguration/RealmConfiguration as the identifier for the Realm. This is also why it is immutable.

But like @Zhuinden says, a good workaround is implementing equals/hashcode in way that make your two error handlers equal.

cmelchior avatar Jul 20 '17 07:07 cmelchior

ok thank,the issuse can be closed.

idok595 avatar Jul 20 '17 16:07 idok595