From 425c57b22fa85811ff6c4e1461cdc5b730e869fa Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 23 Mar 2015 08:47:33 +0000 Subject: [PATCH] FST.save can truncate output (BufferedOutputStream may be closed after the underlying stream) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1668551 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ lucene/core/src/java/org/apache/lucene/util/fst/FST.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 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)); } }