Skip to content

Apache Lucene open-source search software

FST.save can truncate output (BufferedOutputStream may be closed after the underlying stream)

Dawid Weiss425c57b22fa8
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index eeb53b82975..ad1cd2dd526 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -64,6 +64,9 @@ New Features
Bug Fixes
+* LUCENE-6368: FST.save can truncate output (BufferedOutputStream may be closed
+ after the underlying stream). (Ippei Matsushima via Dawid Weiss)
+
* LUCENE-6249: StandardQueryParser doesn't support pure negative clauses.
(Dawid Weiss)
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
index 552e5135d6d..1cf2f04229e 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
@@ -605,8 +605,8 @@ public final class FST<T> implements Accountable {
* Writes an automaton to a file.
*/
public void save(final Path path) throws IOException {
- try (OutputStream os = Files.newOutputStream(path)) {
- save(new OutputStreamDataOutput(new BufferedOutputStream(os)));
+ try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(path))) {
+ save(new OutputStreamDataOutput(os));
}
}