Uploaded image for project: 'Realm Java SDK'
  1. Realm Java SDK
  2. RJAVA-251

Add hint to documentation that RealmMigration implementation should override equals() and hashCode()

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      Problem

      I don't understand the reason, but under some circumstances concerning multithreading the following exception will not be printed:

      java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file. The most likely cause is that equals() and hashCode() are not overridden in the migration class: package.MigrationClass
                                                             at io.realm.RealmCache.validateConfiguration(RealmCache.java:450)
                                                             at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:339)
                                                             at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:281)
                                                             at io.realm.Realm.getInstance(Realm.java:346)
      

      Instead the background thread will get terminated without any feedback. I produced this stacktrace by accident, while making a call to my realm database on the main thread instead of on a background thread. Even if you can't figure out the reason for this either it would be awesome to have an hint in the documentation that an implementation of "RealmMigration" should override equals and hashcode. This would have saved me a couple of hours

      Greets,
      djuelg

      Version of Realm and tooling

      Realm version(s): 3.7.2

      Realm sync feature enabled: no

      Android Studio version: 2.3.3

      Which Android version and device: OnePlus 3T (API 25), Emulator (API26)

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: