LUCENE-4209: fix another suggester leak: dont leave behind the file when rename fails (/tmp is its own filesystem)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1359946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-07-10 23:06:08 +00:00
parent 80c852e721
commit 20b748a484
2 changed files with 6 additions and 3 deletions

View File

@ -45,7 +45,8 @@ Bug Fixes
* LUCENE-4209: Fix FSTCompletionLookup to close its sorter, so that it won't * LUCENE-4209: Fix FSTCompletionLookup to close its sorter, so that it won't
leave temp files behind in /tmp. Fix SortedTermFreqIteratorWrapper to not leave temp files behind in /tmp. Fix SortedTermFreqIteratorWrapper to not
leave temp files behind in /tmp on Windows. (Uwe Schindler, Robert Muir) leave temp files behind in /tmp on Windows. Fix Sort to not leave
temp files behind when /tmp is a separate volume. (Uwe Schindler, Robert Muir)
Build Build

View File

@ -224,10 +224,12 @@ public final class Sort {
// One partition, try to rename or copy if unsuccessful. // One partition, try to rename or copy if unsuccessful.
if (merges.size() == 1) { if (merges.size() == 1) {
File single = merges.get(0);
// If simple rename doesn't work this means the output is // If simple rename doesn't work this means the output is
// on a different volume or something. Copy the input then. // on a different volume or something. Copy the input then.
if (!merges.get(0).renameTo(output)) { if (!single.renameTo(output)) {
copy(merges.get(0), output); copy(single, output);
single.delete();
} }
} else { } else {
// otherwise merge the partitions with a priority queue. // otherwise merge the partitions with a priority queue.