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:18:23 UTC
svn commit: r1646889 -
/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java
Author: rmuir
Date: Fri Dec 19 22:18:22 2014
New Revision: 1646889
URL: http://svn.apache.org/r1646889
Log:
LUCENE-6124: fix double-close() bugs in WindowsFS etc
Modified:
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java?rev=1646889&r1=1646888&r2=1646889&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/mockfile/HandleTrackingFS.java Fri Dec 19 22:18:22 2014
@@ -93,9 +93,15 @@ public abstract class HandleTrackingFS e
@Override
public InputStream newInputStream(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(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(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(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(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();
}