Skip to content

Commit c32121f

Browse files
authored
Merge pull request #2001 from idodeclare/bugfix/close_hist_stream
Close stream. Buffer directly from File. Fix arg.
2 parents be85104 + cbf517e commit c32121f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/org/opensolaris/opengrok/history/FileHistoryCache.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
2223
*/
2324

2425
package org.opensolaris.opengrok.history;
@@ -223,13 +224,10 @@ private static File getCachedFile(File file) throws HistoryException,
223224
* Read history from a file.
224225
*/
225226
private static History readCache(File file) throws IOException {
226-
try {
227-
FileInputStream in = new FileInputStream(file);
228-
XMLDecoder d = new XMLDecoder(
229-
new BufferedInputStream(new GZIPInputStream(in)));
227+
try (FileInputStream in = new FileInputStream(file);
228+
XMLDecoder d = new XMLDecoder(new GZIPInputStream(
229+
new BufferedInputStream(in)))) {
230230
return (History) d.readObject();
231-
} catch (IOException e) {
232-
throw e;
233231
}
234232
}
235233

@@ -253,9 +251,8 @@ private void writeHistoryToFile(File dir, History history, File cacheFile) throw
253251
try {
254252
output = File.createTempFile("oghist", null, dir);
255253
try (FileOutputStream out = new FileOutputStream(output);
256-
XMLEncoder e = new XMLEncoder(
257-
new BufferedOutputStream(
258-
new GZIPOutputStream(out)))) {
254+
XMLEncoder e = new XMLEncoder(new GZIPOutputStream(
255+
new BufferedOutputStream(out)))) {
259256
e.setPersistenceDelegate(File.class,
260257
new FilePersistenceDelegate());
261258
e.writeObject(history);

src/org/opensolaris/opengrok/history/HistoryGuru.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.history;
2525

@@ -215,7 +215,7 @@ public History getHistory(File file) throws HistoryException {
215215
}
216216

217217
public History getHistory(File file, boolean withFiles) throws HistoryException {
218-
return getHistory(file, true, false);
218+
return getHistory(file, withFiles, false);
219219
}
220220

221221
/**

0 commit comments

Comments
 (0)