deepstreamIO / deepstream.io-client-java

The Java/Android Client for deepstream.io
Other
35 stars 37 forks source link

Fixed thread safety problems in RecordHandler #110

Closed fhriley closed 7 years ago

fhriley commented 7 years ago

This commit fixes the most obvious thread safety issues in RecordHandler. However, from looking at the code, I suspect there are other more difficult to spot issues. For example, here is one (t1 and t2 are independent threads):

t1 - foo_t1 = client.record.getRecord("foo") t1 - foo_t1.discard() preempts just after if( this.usages <= 0 ) t2 - foo_t2 = client.record.getRecord("foo") t1 - resumes and finishes foo_t1.discard() t2 - resumes and is now using a record that had destroy() called on it

Do I understand this correctly? If so, do you have a particular way you'd like to fix it?

fhriley commented 7 years ago

The second commit fixes the thread safety issue I described in my previous comment.