Wednesday, March 4, 2015

Re: (Server-side) AutoBeans and thread-safety



On Tuesday, February 24, 2015 at 6:56:50 PM UTC+1, Andreas Kohn wrote:
I understand that autobean's are actually parsed lazily, so for me this looks like a concurrency issue somewhere inside the autobeans framework itself. I didn't see any notes about sharing autobeans between threads in the documentation, so:
1. Should it be possible to share them, or is additional synchronization in the application code needed?
2. Instead of synchronizing all accesses, would it be enough to force a full parse run of the autobean before making it visible to other threads?
3. Is this problem only affecting server-side code, or would similar issues also be possible in client-side code? (I'm suspecting: "It depends on the browser's implementation of JS?")

Regarding the second question: I did not manage to reproduce the issue by using this additional code:
AutoBeanUtils.getAutoBean(delegate).accept(new AutoBeanVisitor() { /* Nothing */ });



Small update here: I was able to get my test to break again even after using the #accept() idea, by using a Map property in the bean, and iterating over its entry set. So my conclusion here: using autobeans on the server side without external synchronization and careful coding is dangerous.

I've now worked around this issue by copying the contents of the bean into a separate class that implements the bean interface as well. In my case I do not need the ability to modify the contents, so I didn't bother working out how I'd get my copy serialized into JSON again.

Regards,
--
Andreas

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment