You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/10/03 17:22:53 UTC

svn commit: r1393535 - /lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java

Author: mikemccand
Date: Wed Oct  3 15:22:53 2012
New Revision: 1393535

URL: http://svn.apache.org/viewvc?rev=1393535&view=rev
Log:
handle Throwable not just IOE when closing

Modified:
    lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java

Modified: lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java?rev=1393535&r1=1393534&r2=1393535&view=diff
==============================================================================
--- lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java (original)
+++ lucene/dev/branches/slowclosing/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java Wed Oct  3 15:22:53 2012
@@ -334,13 +334,13 @@ final class StandardDirectoryReader exte
 
   @Override
   protected void doClose() throws IOException {
-    IOException ioe = null;
+    Throwable firstExc = null;
     for (final AtomicReader r : getSequentialSubReaders()) {
       // try to close each reader, even if an exception is thrown
       try {
         r.decRef();
-      } catch (IOException e) {
-        if (ioe == null) ioe = e;
+      } catch (Throwable t) {
+        if (t == null) firstExc = t;
       }
     }
 
@@ -351,7 +351,12 @@ final class StandardDirectoryReader exte
     }
 
     // throw the first exception
-    if (ioe != null) throw ioe;
+    if (firstExc != null) {
+      if (firstExc instanceof IOException) throw (IOException) firstExc;
+      if (firstExc instanceof RuntimeException) throw (RuntimeException) firstExc;
+      if (firstExc instanceof Error) throw (Error) firstExc;
+      throw new RuntimeException(firstExc);
+    }
   }
 
   @Override