pushtorefresh / storio

Reactive API for SQLiteDatabase and ContentResolver.
Apache License 2.0
2.55k stars 182 forks source link

Transaction exception -- java.util.ConcurrentModificationException #478

Closed tadas-subonis closed 9 years ago

tadas-subonis commented 9 years ago

Hi,

I am trying to use StorIO in this manner:

                        storIOSQLite.internal().beginTransaction();
                        try {
                            storIOSQLite
                                    .put()
                                    .objects(localStreamEntries)
                                    .withPutResolver(streamEntryPutResolver)
                                    .useTransaction(true)
                                    .prepare()
                                    .executeAsBlocking();

                            storIOSQLite
                                    .put()
                                    .objects(otherListWithOtherType)
                                    .withPutResolver(localStreamLoadingPutResolver)
                                    .useTransaction(true)
                                    .prepare()
                                    .executeAsBlocking();

                            storIOSQLite.internal().setTransactionSuccessful();
                        } finally {
                            storIOSQLite.internal().endTransaction();
                        }

And I get this exception

java.util.ConcurrentModificationException
            at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
            at java.util.HashMap$KeyIterator.next(HashMap.java:814)
            at com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite$InternalImpl.notifyAboutPendingChangesIfNotInTransaction(DefaultStorIOSQLite.java:391)
            at com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite$InternalImpl.endTransaction(DefaultStorIOSQLite.java:435)
artem-zinnatullin commented 9 years ago

I'll prepare fix ASAP, thanks for report!

artem-zinnatullin commented 9 years ago

BTW, you don't need to write useTransaction(true) explicitly because it's true by default :)

tadas-subonis commented 9 years ago

Thanks :)

artem-zinnatullin commented 9 years ago

Fixed by #479, sorry it was my stupid mistake in the code :(

It was not even related to concurrency.

artem-zinnatullin commented 9 years ago

@tadas-subonis we've just released StorIO v1.1.1, it should be available in about 10-20 minutes, thanks for report, sorry for bug and have a nice day!

tadas-subonis commented 9 years ago

That was very quick! Thanks!

On Tue, Aug 4, 2015 at 6:15 PM, Artem Zinnatullin notifications@github.com wrote:

@tadas-subonis https://github.com/tadas-subonis we've just released StorIO v1.1.1, it should be available in about 10-20 minutes, thanks for report, sorry for bug and have a nice day!

— Reply to this email directly or view it on GitHub https://github.com/pushtorefresh/storio/issues/478#issuecomment-127645944 .

Kind Regards, Tadas Šubonis