Author: kristwaa
Date: Fri Mar 9 08:33:03 2012
New Revision: 1298751
URL: http://svn.apache.org/viewvc?rev=1298751&view=rev
Log:
DERBY-5603: EmbedConnection.clearLOBMapping() incorrectly clears lobFiles causing a ConcurrentModificationException
Merged fix from trunk (revision 1294512).
Modified:
db/derby/code/branches/10.4/ (props changed)
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
Propchange: db/derby/code/branches/10.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 9 08:33:03 2012
@@ -1,3 +1,3 @@
/db/derby/code/branches/10.5:814216,904472,958230,1132842,1132844
/db/derby/code/branches/10.6:1055601
-/db/derby/code/trunk:788436,788968,793588,794303,796316,796372,797147,798347,798742,800523,803548,805696,809643,812669,816536,835286,882732,898635,903108,915177,915733,917771,928065,934996,946794,954544,958163,958230,959550,980684,999119,1053724,1057542,1062096
+/db/derby/code/trunk:788436,788968,793588,794303,796316,796372,797147,798347,798742,800523,803548,805696,809643,812669,816536,835286,882732,898635,903108,915177,915733,917771,928065,934996,946794,954544,958163,958230,959550,980684,999119,1053724,1057542,1062096,1294512
Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1298751&r1=1298750&r2=1298751&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
Fri Mar 9 08:33:03 2012
@@ -2924,8 +2924,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 ();
@@ -2939,18 +2937,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;
+ }
}
}
}
@@ -2999,7 +3004,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();
}
|