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?
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 astoRawQuery()
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 ofmTables
in the constructor, so that there is no shared state?