zendesk / android-db-commons

Some common utilities for ContentProvider/ContentResolver/Cursor and other db-related android stuff
Apache License 2.0
222 stars 28 forks source link

Fix ConcurrentModificationException #92

Closed maciejwitowski closed 3 years ago

lmac012 commented 3 years ago

The way I understand this, the root cause seems to be the fact that an instance of CompoundQueryPart created with its copying constructor shares some mutable state with the original instance. With the "right" timing, any method in that class (such as toRawQuery() in this specific example) that assumes the class state can't be concurrently modified, can fail. If that is the case, why not fix this by making a deep copy of mTables in the constructor, so that there is no shared state?

maciejwitowski commented 3 years ago

@lmac012 Good idea, it's better to copy the mQueryBuilder asap (in constructor) instead of waiting until it's used.