User: patriot1burke
Date: 01/10/18 13:32:39
Modified: src/main/org/jboss/ejb/plugins Tag: Branch_2_4
EntitySynchronizationInterceptor.java
EntityInstanceInterceptor.java
Log:
code was incorrectly locking bean and inserting bean in invokeHome even if there
was an exception thrown. This is wrong.
Revision Changes Path
No revision
No revision
1.37.2.3 +25 -25
jboss/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
Index: EntitySynchronizationInterceptor.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java,v
retrieving revision 1.37.2.2
retrieving revision 1.37.2.3
diff -u -r1.37.2.2 -r1.37.2.3
--- EntitySynchronizationInterceptor.java 2001/10/11 16:34:20 1.37.2.2
+++ EntitySynchronizationInterceptor.java 2001/10/18 20:32:39 1.37.2.3
@@ -57,7 +57,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>
- * @version $Revision: 1.37.2.2 $
+ * @version $Revision: 1.37.2.3 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/06/28: marcf</b>
@@ -103,6 +103,10 @@
* <ol>
* <li>do not call cache.release if entity has been removed
* </ol>
+* <p><b>2001/10/18: billb</b>
+* <ol>
+* <li>Do not lock bean on an exception
+* </ol>
*/
public class EntitySynchronizationInterceptor
extends AbstractInterceptor
@@ -230,35 +234,31 @@
EntityEnterpriseContext ctx =
(EntityEnterpriseContext)mi.getEnterpriseContext();
Transaction tx = mi.getTransaction();
- try
- {
- return getNext().invokeHome(mi);
- } finally
- {
-
- // An anonymous context was sent in, so if it has an id it is a real
instance now
- if (ctx.getId() != null)
+ Object rtn = getNext().invokeHome(mi);
+
+ // An anonymous context was sent in, so if it has an id it is a real instance
now
+ if (ctx.getId() != null)
+ {
+
+ // Currently synched with underlying storage
+ ctx.setValid(true);
+
+ if (tx!= null)
{
-
- // Currently synched with underlying storage
- ctx.setValid(true);
-
- if (tx!= null)
+ BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey());
+ try
+ {
+ lock.schedule(mi);
+ register(ctx, tx); // Set tx
+ lock.releaseMethodLock();
+ }
+ finally
{
- BeanLock lock =
container.getLockManager().getLock(ctx.getCacheKey());
- try
- {
- lock.schedule(mi);
- register(ctx, tx); // Set tx
- lock.releaseMethodLock();
- }
- finally
- {
- container.getLockManager().removeLockRef(lock.getId());
- }
+ container.getLockManager().removeLockRef(lock.getId());
}
}
}
+ return rtn;
}
public Object invoke(MethodInvocation mi)
1.30.2.3 +29 -29
jboss/src/main/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
Index: EntityInstanceInterceptor.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/EntityInstanceInterceptor.java,v
retrieving revision 1.30.2.2
retrieving revision 1.30.2.3
diff -u -r1.30.2.2 -r1.30.2.3
--- EntityInstanceInterceptor.java 2001/09/04 01:51:07 1.30.2.2
+++ EntityInstanceInterceptor.java 2001/10/18 20:32:39 1.30.2.3
@@ -61,7 +61,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>
-* @version $Revision: 1.30.2.2 $
+* @version $Revision: 1.30.2.3 $
*
* <p><b>Revisions:</b><br>
* <p><b>2001/06/28: marcf</b>
@@ -105,6 +105,10 @@
* <li> For the record, locking went from cache (early 2.0) -> this interceptor ->
new interceptor
* <li> new locking is pluggable
* </ol>
+* <p><b>2001/10/18: billb</b>
+* <ol>
+* <li>Do not insert bean into cache on an exception
+* </ol>
*/
public class EntityInstanceInterceptor
extends AbstractInterceptor
@@ -147,38 +151,34 @@
// Give it the transaction
ctx.setTransaction(mi.getTransaction());
-
- try
+
+ boolean exceptionThrown = false;
+
+ // Invoke through interceptors
+ Object rtn = getNext().invokeHome(mi);
+
+ // Is the context now with an identity? in which case we need to insert
+ if (ctx.getId() != null)
{
- // Invoke through interceptors
- return getNext().invokeHome(mi);
- }
- finally
- {
-
- // Is the context now with an identity? in which case we need to insert
- if (ctx.getId() != null)
+
+ BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey());
+
+ lock.sync(); // lock all access to BeanLock
+
+ try
+ {
+ // marcf: possible race on creation and usage
+ // insert instance in cache,
+ container.getInstanceCache().insert(ctx);
+
+ }
+ finally
{
-
- BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey());
-
- lock.sync(); // lock all access to BeanLock
-
- try
- {
- // marcf: possible race on creation and usage
- // insert instance in cache,
- container.getInstanceCache().insert(ctx);
-
- }
- finally
- {
- lock.releaseSync();
- container.getLockManager().removeLockRef(ctx.getCacheKey());
- }
+ lock.releaseSync();
+ container.getLockManager().removeLockRef(ctx.getCacheKey());
}
- //Do not send back to pools in any case, let the instance be GC'ed
}
+ return rtn;
}
public Object invoke(MethodInvocation mi)
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development