19
19
20
20
/*
21
21
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
22
+ * Portions Copyright (c) 2018, Chris Fraire <[email protected] >.
22
23
*/
23
24
24
25
package org .opensolaris .opengrok .history ;
@@ -223,13 +224,10 @@ private static File getCachedFile(File file) throws HistoryException,
223
224
* Read history from a file.
224
225
*/
225
226
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 )))) {
230
230
return (History ) d .readObject ();
231
- } catch (IOException e ) {
232
- throw e ;
233
231
}
234
232
}
235
233
@@ -253,9 +251,8 @@ private void writeHistoryToFile(File dir, History history, File cacheFile) throw
253
251
try {
254
252
output = File .createTempFile ("oghist" , null , dir );
255
253
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 )))) {
259
256
e .setPersistenceDelegate (File .class ,
260
257
new FilePersistenceDelegate ());
261
258
e .writeObject (history );
0 commit comments