[jboss-dev-forums] [Design of JCA on JBoss] - Re: [JBAS-5095] Race condition between connection.close() an
adrian@jboss.org
do-not-reply at jboss.com
Thu Jul 24 08:24:32 EDT 2008
"adrian at jboss.org" wrote :
| The fix is to replace isManagedConnectionFree() with wasManagedConnectionFreed().
| i.e. the managed connection might now be free, but it wasn't us that freed it
| => do it only once
|
Of course, that's only a logical description of what it should do.
In practice the code is more complicated.
But the key part is to have some synchronized block that maintains/checks
the free state.
e.g. something like
| synchronized boolean isFreed(...)
| {
| boolean wasFree = isManagedConnectionFree();
| // change state, e.g. #handles or track-by-tx
| if (wasFree)
| return false; // This shouldn't really happen now all the state is changed atomically
| else
| return isManagedConnectionFree(); // We just freed it
| }
|
| if (isFreed(...))
| returnManagedConnection();
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166398#4166398
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166398
More information about the jboss-dev-forums
mailing list