db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1294512 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
Date Tue, 28 Feb 2012 08:01:18 GMT
Author: kristwaa
Date: Tue Feb 28 08:01:18 2012
New Revision: 1294512

URL: http://svn.apache.org/viewvc?rev=1294512&view=rev
Log:
DERBY-5603: EmbedConnection.clearLOBMapping() incorrectly clears lobFiles causing a ConcurrentModificationException


Rewrote map iteration code.
Fixed incorrect comment.
Made getlobHMObj private.

Patch file: derby-5603-1a-avoid_concurrentmodification.diff

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1294512&r1=1294511&r2=1294512&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Feb
28 08:01:18 2012
@@ -3262,8 +3262,6 @@ public abstract class EmbedConnection im
 	public void clearLOBMapping() throws SQLException {
 
 		//free all the lob resources in the HashMap
-		//initialize the locator value to 0 and
-		//the hash table object to null.
 		Map map = rootConnection.lobReferences;
 		if (map != null) {
             Iterator it = map.keySet ().iterator ();
@@ -3277,18 +3275,25 @@ public abstract class EmbedConnection im
         }
 		
 		synchronized (this) {   
+            // Try a bit harder to close all open files, as open file handles
+            // can cause problems further down the road.
 			if (lobFiles != null) {       
+                SQLException firstException = null;
 				Iterator it = lobFiles.iterator();
-				while (it.hasNext()) {
-					try {
-						((LOBFile) it.next()).close();
-					} catch (IOException ioe) {
-						throw Util.javaException(ioe);
-					}
-					finally {
-						lobFiles.clear();
-					}
-				}
+                while (it.hasNext()) {
+                    try {
+                        ((LOBFile) it.next()).close();
+                    } catch (IOException ioe) {
+                        // Discard all exceptions besides the first one.
+                        if (firstException == null) {
+                            firstException = Util.javaException(ioe);
+                        }
+                    }
+                }
+                lobFiles.clear();
+                if (firstException != null) {
+                    throw firstException;
+                }
 			}
 		}
 	}
@@ -3337,7 +3342,7 @@ public abstract class EmbedConnection im
 	* Return the Hash Map in the root connection
 	* @return the HashMap that contains the locator to LOB object mapping
 	*/
-	public HashMap getlobHMObj() {
+	private HashMap getlobHMObj() {
 		if (rootConnection.lobHashMap == null) {
 			rootConnection.lobHashMap = new HashMap();
 		}



Mime
View raw message