myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r551518 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
Date Thu, 28 Jun 2007 09:39:53 GMT
Author: imario
Date: Thu Jun 28 02:39:52 2007
New Revision: 551518

URL: http://svn.apache.org/viewvc?view=rev&rev=551518
Log:
fixed concurrent modification exception

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java?view=diff&rev=551518&r1=551517&r2=551518
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
(original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
Thu Jun 28 02:39:52 2007
@@ -26,7 +26,6 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -86,12 +85,16 @@
 
 	public static void releaseAllBorrowedConnections()
 	{
-	 	Iterator iterBorrowedConnections = ((Set) borrowedConnections.get()).iterator();
-		while (iterBorrowedConnections.hasNext())
+		DisconnectableConnection[] connections = new DisconnectableConnection[((Set) borrowedConnections.get()).size()];
+		((Set) borrowedConnections.get()).toArray(connections);
+
+		for (int i = 0; i<connections.length; i++)
 		{
-			DisconnectableConnection connection = (DisconnectableConnection) iterBorrowedConnections.next();
+			DisconnectableConnection connection = connections[i];
 			connection.disconnect();
 		}
+
+		((Set) borrowedConnections.get()).clear();
 	}
 
 	public void setListeners(ConnectionManagerListener[] listeners)



Mime
View raw message