Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r14880 -
 core/patches/JBOSS_EAP_3_2_4_SP1_CP01_JBPAPP-883/src/org/hibernate/jdbc.

hibernate-commits

2008-07-07


Author LoginPost Reply
Author: cbredesen
Date: 2008-07-07 09:08:15 -0400 (Mon, 07 Jul 2008)
New Revision: 14880

Modified:
 core/patches/JBOSS_EAP_3_2_4_SP1_CP01_JBPAPP-883/src/org/hibernate/jdbc/AbstractBatcher.java
Log:
JBPAPP-883 explicitly handling ConcurrentModificationException

Modified: core/patches/JBOSS_EAP_3_2_4_SP1_CP01_JBPAPP-883/src/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- core/patches/JBOSS_EAP_3_2_4_SP1_CP01_JBPAPP-883/src/org/hibernate/jdbc/AbstractBatcher.java  2008-07-05 19:25:36 UTC (rev 14879)
+++ core/patches/JBOSS_EAP_3_2_4_SP1_CP01_JBPAPP-883/src/org/hibernate/jdbc/AbstractBatcher.java  2008-07-07 13:08:15 UTC (rev 14880)
@@(protected) @@
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.ConcurrentModificationException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@(protected) @@
     releasing = true;

     try {
-        if (batchUpdate!=null) batchUpdate.close();
+        if ( batchUpdate != null ) {
+          batchUpdate.close();
+        }
     }
     catch (SQLException sqle) {
       //no big deal
@@(protected) @@
         // no big deal
         log.warn("Could not close a JDBC result set", e);
       }
-        catch (Throwable e) {
-          // sybase driver (jConnect) throwing NPE here in certain cases
-          log.warn("Could not close a JDBC result set", e);
+        catch ( ConcurrentModificationException e ) {
+          // this has been shown to happen occasionally in rare cases
+          // when using a transaction manager + transaction-timeout
+          // where the timeout calls back through Hibernate's
+          // registered transaction synchronization on a separate
+          // "reaping" thread. In cases where that reaping thread
+          // executes through this block at the same time the main
+          // application thread does we can get into situations where
+          // these CMEs occur. And though it is not "allowed" per-se,
+          // the end result without handling it specifically is infinite
+          // looping. So here, we simply break the loop
+          log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+          break;
       }
+        catch ( Throwable e ) {
+          // sybase driver (jConnect) throwing NPE here in certain
+          // cases, but we'll just handle the general "unexpected" case
+          log.warn( "Could not close a JDBC result set", e );
+        }
     }
     resultSetsToClose.clear();

@@(protected) @@
       try {
         closeQueryStatement( (PreparedStatement) iter.next() );
       }
+        catch ( ConcurrentModificationException e ) {
+          // see explanation above...
+          log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+          break;
+        }
       catch (SQLException e) {
         // no big deal
         log.warn("Could not close a JDBC statement", e);

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.