RealmResult iterators now detect changes to underlying tableview.

RealmResults now correctly identify any changes to the underlying query tableview and throws a ConcurrentModificationException if detected.

@kneth @bmunkholm @emanuelez 
Good point. I think I know what's it about.

On Thu, Nov 27, 2014 at 11:09 PM, Christian Melchior <
notifications@github.com> wrote:

> In realm/src/androidTest/java/io/realm/RealmResultsIteratorTests.java:
>
> > +        } catch (IllegalStateException ignored) {
> > +            return;
> > +        } finally {
> > +            testRealm.cancelTransaction();
> > +        }
> > +
> > +        fail("You can only make one call to remove() after calling next() pr. the JavaDoc");
> > +    }
> > +
> > +
> > +
> > +    // Using size() as heuristic for concurrent modifications is dangerous as we might skip
> > +    // elements.
> > +    // TODO Possible bug: Why does this interfer with reference counting check. They are separate Realm files.
> > +    // TODO Possible bug: Why is realm.refresh() needed?
> > +    public void testRemovingObjectsFromOtherThreadWhileIterating() throws InterruptedException, ExecutionException {
>
> @emanuelez <https://github.com/emanuelez> @bmunkholm
> <https://github.com/bmunkholm> I am a bit concerned about this unit test
> and its implications.
>
> 1) I open a non-default Realm called "test" and still the reference
> counting unit test fails if both RealmTests and this class is run.
>
> 2) I need to do Realm.refresh() on the Main thread to get notifications
> from the background thread. Main thread has notifications enabled,
> background thread does not.
>
> We probably don't need to fix it in the PR, but should investigate on
> another branch.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/realm/realm-java/pull/603/files#r21012151>.
>



-- 
*Emanuele Zattin* (@emanuelez <https://twitter.com/emanuelez>)
SW Engineer & CI Specialist