Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseObjectCoder.encode is not thread-safe #76

Closed
hallucinogen opened this issue Aug 27, 2015 · 5 comments
Closed

ParseObjectCoder.encode is not thread-safe #76

hallucinogen opened this issue Aug 27, 2015 · 5 comments
Assignees

Comments

@hallucinogen
Copy link
Contributor

ParseObjectCoder.encode signature accepts ParseObject.State, ParseOperationSet and ParseEncoder. While ParseObject.State and ParseEncoder is immutable and thread-safe, ParseOperationSet can be mutated anytime and is not guarded by any mutex. We need to either guard the ParseOperationSet with mutex or make a copy of this ParseOperationSet somewhere and pass the copy to ParseObjectCoder.encode.

@hallucinogen
Copy link
Contributor Author

This is an example of how ParseObjectCoder.encode is not thread-safe: https://github.com/ParsePlatform/Parse-SDK-Android/blob/master/Parse/src/main/java/com/parse/NetworkUserController.java#L41

Though we can argue that every call to NetworkUserController will be guarded by ParseUser's taskQueue.

@lukas1994
Copy link
Contributor

We could make a deep-copy of the operation set in encode() but that might not be very efficient. What do you think?

@hallucinogen
Copy link
Contributor Author

Deep-copy won't solve the problem I mentioned in #78.

@lukas1994
Copy link
Contributor

from #78 :
I checked all places where ParseOperationSet is used and couldn't find any concurrency issues.
The scenario you described above can't happen because if save() gets called a new ParseOperationSet gets enqueued (to operationSetQueue) and all methods mutate the top of the queue.

@lukas1994 lukas1994 assigned hallucinogen and unassigned lukas1994 Sep 1, 2015
@hallucinogen
Copy link
Contributor Author

Sounds good. Closing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants