You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/12/19 23:31:40 UTC

svn commit: r1646898 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java

Author: rmuir
Date: Fri Dec 19 22:31:40 2014
New Revision: 1646898

URL: http://svn.apache.org/r1646898
Log:
LUCENE-6124: fix double-close() bugs in WindowsFS etc

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java?rev=1646898&r1=1646897&r2=1646898&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java Fri Dec 19 22:31:40 2014
@@ -93,9 +93,15 @@ public abstract class HandleTrackingFS e
   @Override
   public InputStream newInputStream(final Path path, OpenOption... options) throws IOException {
     InputStream stream = new FilterInputStream2(super.newInputStream(path, options)) {
+      
+      boolean closed;
+      
       @Override
       public void close() throws IOException {
-        onClose(path, this);
+        if (!closed) {
+          closed = true;
+          onClose(path, this);
+        }
         super.close();
       }
 
@@ -121,9 +127,15 @@ public abstract class HandleTrackingFS e
   @Override
   public OutputStream newOutputStream(final Path path, OpenOption... options) throws IOException {
     OutputStream stream = new FilterOutputStream2(super.newOutputStream(path, options)) {
+      
+      boolean closed;
+
       @Override
       public void close() throws IOException {
-        onClose(path, this);
+        if (!closed) {
+          closed = true;
+          onClose(path, this);
+        }
         super.close();
       }
       
@@ -149,9 +161,15 @@ public abstract class HandleTrackingFS e
   @Override
   public FileChannel newFileChannel(final Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
     FileChannel channel = new FilterFileChannel(super.newFileChannel(path, options, attrs)) {
+      
+      boolean closed;
+      
       @Override
       protected void implCloseChannel() throws IOException {
-        onClose(path, this);
+        if (!closed) {
+          closed = true;
+          onClose(path, this);
+        }
         super.implCloseChannel();
       }
 
@@ -177,9 +195,15 @@ public abstract class HandleTrackingFS e
   @Override
   public AsynchronousFileChannel newAsynchronousFileChannel(final Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs) throws IOException {
     AsynchronousFileChannel channel = new FilterAsynchronousFileChannel(super.newAsynchronousFileChannel(path, options, executor, attrs)) {
+      
+      boolean closed;
+      
       @Override
       public void close() throws IOException {
-        onClose(path, this);
+        if (!closed) {
+          closed = true;
+          onClose(path, this);
+        }
         super.close();
       }
 
@@ -205,9 +229,15 @@ public abstract class HandleTrackingFS e
   @Override
   public SeekableByteChannel newByteChannel(final Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
     SeekableByteChannel channel = new FilterSeekableByteChannel(super.newByteChannel(path, options, attrs)) {
+      
+      boolean closed;
+      
       @Override
       public void close() throws IOException {
-        onClose(path, this);
+        if (!closed) {
+          closed = true;
+          onClose(path, this);
+        }
         super.close();
       }
 
@@ -237,9 +267,15 @@ public abstract class HandleTrackingFS e
       stream = new TrackingSecureDirectoryStream((SecureDirectoryStream<Path>)stream, dir);
     } else {
       stream = new FilterDirectoryStream<Path>(stream) {
+        
+        boolean closed;
+        
         @Override
         public void close() throws IOException {
-          onClose(dir, this);
+          if (!closed) {
+            closed = true;
+            onClose(dir, this);
+          }
           super.close();
         }
         
@@ -271,10 +307,15 @@ public abstract class HandleTrackingFS e
       super(delegate);
       this.dir = dir;
     }
+    
+    boolean closed;
 
     @Override
     public void close() throws IOException {
-      onClose(dir, this);
+      if (!closed) {
+        closed = true;
+        onClose(dir, this);
+      }
       super.close();
     }
     
@@ -303,9 +344,15 @@ public abstract class HandleTrackingFS e
     @Override
     public SeekableByteChannel newByteChannel(final Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
       SeekableByteChannel channel = new FilterSeekableByteChannel(super.newByteChannel(path, options, attrs)) {
+        
+        boolean closed;
+        
         @Override
         public void close() throws IOException {
-          onClose(path, this);
+          if (!closed) {
+            closed = true;
+            onClose(path, this);
+          }
           super.close();
         }