You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2014/12/31 16:52:02 UTC
svn commit: r1648724 - in /lucene/dev/trunk/lucene: CHANGES.txt
core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java
Author: uschindler
Date: Wed Dec 31 15:52:01 2014
New Revision: 1648724
URL: http://svn.apache.org/r1648724
Log:
LUCENE-6152: Fix double close bug in OutputStreamIndexOutput
Modified:
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1648724&r1=1648723&r2=1648724&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Wed Dec 31 15:52:01 2014
@@ -400,6 +400,9 @@ Bug Fixes
* LUCENE-6124: Fix double-close() problems in codec and store APIs.
(Robert Muir)
+* LUCENE-6152: Fix double close problems in OutputStreamIndexOutput.
+ (Uwe Schindler)
+
Documentation
* LUCENE-5392: Add/improve analysis package documentation to reflect
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java?rev=1648724&r1=1648723&r2=1648724&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/OutputStreamIndexOutput.java Wed Dec 31 15:52:01 2014
@@ -30,6 +30,7 @@ public class OutputStreamIndexOutput ext
private final BufferedOutputStream os;
private long bytesWritten = 0L;
+ private boolean flushedOnClose = false;
/**
* Creates a new {@link OutputStreamIndexOutput} with the given buffer size.
@@ -58,9 +59,14 @@ public class OutputStreamIndexOutput ext
try (final OutputStream o = os) {
// We want to make sure that os.flush() was running before close:
// BufferedOutputStream may ignore IOExceptions while flushing on close().
- // TODO: this is no longer an issue in Java 8:
- // http://hg.openjdk.java.net/jdk8/tl/jdk/rev/759aa847dcaf
- o.flush();
+ // We keep this also in Java 8, although it claims to be fixed there,
+ // because there are more bugs around this! See:
+ // # https://bugs.openjdk.java.net/browse/JDK-7015589
+ // # https://bugs.openjdk.java.net/browse/JDK-8054565
+ if (!flushedOnClose) {
+ flushedOnClose = true; // set this BEFORE calling flush!
+ o.flush();
+ }
}
}