yahel / rangzen

1 stars 0 forks source link

ConcurrentModificationException on SharedPreferences #12

Open scrivener opened 9 years ago

scrivener commented 9 years ago

Had a crash when I pressed Send on a message once. Exception is below, it was a ConcurrentModificationException related to the SharedPreferences. I guess it's something wrong with concurrent access to the message store? Worth trying to hunt down... maybe it's related to adding a message during an exchange?

01-21 16:42:54.308: E/AndroidRuntime(3747): FATAL EXCEPTION: pool-2-thread-1
01-21 16:42:54.308: E/AndroidRuntime(3747): Process: org.denovogroup.rangzen, PID: 3747
01-21 16:42:54.308: E/AndroidRuntime(3747): java.util.ConcurrentModificationException
01-21 16:42:54.308: E/AndroidRuntime(3747):     at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at java.util.HashMap$KeyIterator.next(HashMap.java:833)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at com.android.internal.util.XmlUtils.writeSetXml(XmlUtils.java:298)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at com.android.internal.util.XmlUtils.writeValueXml(XmlUtils.java:447)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:241)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:181)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:596)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-21 16:42:54.308: E/AndroidRuntime(3747):     at java.lang.Thread.run(Thread.java:841)
scrivener commented 9 years ago

I was able to trigger this by deleting Rangzen's app data in the Apps pane of the Settings, then launching Rangzen again.

scrivener commented 9 years ago

The integrated bandwidth branch can also trigger this if dummy messages are added to the store AFTER networking capabilities are brought online in onCreate of RangzenService.

scrivener commented 9 years ago

Suggested solution: use a static singleton of MessageStore and/or FriendStore and/or StorageBase. Synchronize its methods.