commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject [POOL] Test failures
Date Wed, 17 Mar 2010 20:53:24 GMT
One of the POOL test cases is failing - 
TestSoftRefOutOfMemory.testOutOfMemoryError()

I can't see any recent code changes that may have caused this and I 
think the recent removal of the testAll code is what has exposed this. 
On the basis that always catching Throwable is bad, but there are many 
cases POOL does need to catch, what do folks here think to the liberal 
application of the following anywhere POOL catches Throwable?

Index: src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java
===================================================================
--- src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java 
(revision 924253)
+++ src/java/org/apache/commons/pool/impl/SoftReferenceObjectPool.java 
(working copy)
@@ -106,10 +106,18 @@
                          throw new Exception("ValidateObject failed");
                      }
                  } catch (Throwable t) {
+                    if (t instanceof VirtualMachineError) {
+                        // Always throw VM errors immediately
+                        throw (VirtualMachineError) t;
+                    }
                      try {
                          _factory.destroyObject(obj);
                      } catch (Throwable t2) {
-                        // swallowed
+                        if (t2 instanceof VirtualMachineError) {
+                            // Always throw VM errors immediately
+                            throw (VirtualMachineError) t2;
+                        }
+                        // Otherwise swallowed
                      } finally {
                          obj = null;
                      }

This fixes the current test failures but really should be applied to all 
places where Throwable is caught.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message