Tuesday, February 24, 2015

(Server-side) AutoBeans and thread-safety


I hope this is the right forum to also ask questions about the Autobeans framework, if not please do redirect me!

We're using autobeans both in client code and server code, and so far things work nicely except in one situation: sometimes parsing autobeans simply fails with a stack trace similar to this:
at com
at com
at com
at com
at com
at com
.sun.proxy.$Proxy368.get(Unknown Source)
at com
at com
at com
at sun
.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun
at java
at com
at com
.sun.proxy.$Proxy347.next(Unknown Source)
at XXX

When dumping the contents of the bean at that point everything looks proper, and it can be parsed just fine in an isolated unit test. After some more investigation I managed to reproduce this and other similar exceptions: it seems to happen when multiple threads access a recently created autobean proxy.

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 */ });


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