[hibernate-commits] Hibernate SVN: r17540 - in core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851: src/org/hibernate/cfg and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Sep 24 16:46:38 EDT 2009


Author: bmaxwell
Date: 2009-09-24 16:46:38 -0400 (Thu, 24 Sep 2009)
New Revision: 17540

Modified:
   core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/build.xml
   core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/cfg/Environment.java
   core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/jdbc/AbstractBatcher.java
Log:
[JBPAPP-2851] fix HHH-3006 - ConcurrentModificationException in AbstractBatcher results in infinite loop for one off patch

Modified: core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/build.xml
===================================================================
--- core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/build.xml	2009-09-24 16:55:13 UTC (rev 17539)
+++ core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/build.xml	2009-09-24 20:46:38 UTC (rev 17540)
@@ -23,7 +23,7 @@
 	<property name="version.major" value="3"/>
 	<property name="version.minor" value="2"/>
 	<property name="version.micro" value="4"/>
-    <property name="version.qualifier" value="sp1"/>
+    <property name="version.qualifier" value="sp1.JBPAPP-883"/>
     <property name="version.cp" value="cp03"/>
     <property name="version.full" value="${version.major}.${version.minor}.${version.micro}.${version.qualifier}.${version.cp}"/>
     <property name="version.major_minor" value="${version.major}.${version.minor}"/>

Modified: core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/cfg/Environment.java
===================================================================
--- core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/cfg/Environment.java	2009-09-24 16:55:13 UTC (rev 17539)
+++ core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/cfg/Environment.java	2009-09-24 20:46:38 UTC (rev 17540)
@@ -153,7 +153,7 @@
  */
 public final class Environment {
 
-	public static final String VERSION = "3.2.4.sp1.cp03";
+	public static final String VERSION = "3.2.4.sp1.cp03.JBPAPP-883";
 
 	/**
 	 * <tt>ConnectionProvider</tt> implementor to use when obtaining connections

Modified: core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/jdbc/AbstractBatcher.java	2009-09-24 16:55:13 UTC (rev 17539)
+++ core/patches/JBOSS_EAP_3_2_4_SP1_CP03_JBPAPP-2851/src/org/hibernate/jdbc/AbstractBatcher.java	2009-09-24 20:46:38 UTC (rev 17540)
@@ -8,6 +8,7 @@
 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;
@@ -298,7 +299,9 @@
 			releasing = true;
 
 			try {
-				if (batchUpdate!=null) batchUpdate.close();
+				if ( batchUpdate != null ) {
+					batchUpdate.close();
+				}
 			}
 			catch (SQLException sqle) {
 				//no big deal
@@ -317,10 +320,25 @@
 					// 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();
 
@@ -329,6 +347,11 @@
 				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);



More information about the hibernate-commits mailing list