Cleanups: Close resources via try-finally

This commit is contained in:
str4d
2018-02-17 19:53:30 +00:00
parent fb6eea2484
commit acebd2ea68
3 changed files with 19 additions and 15 deletions

View File

@@ -261,7 +261,10 @@ public class SingleFileNamingService extends NamingService {
if (out != null) try { out.close(); } catch (IOException e) {}
_log.error("Error adding " + hostname, ioe);
return false;
} finally { releaseWriteLock(); }
} finally {
if (out != null) try { out.close(); } catch (IOException e) {}
releaseWriteLock();
}
}
/**

View File

@@ -394,12 +394,11 @@ public class TranslateReader extends FilterReader {
}
private static void test(String file) throws IOException {
FileInputStream fio = new FileInputStream(file);
TranslateReader r = null;
try {
r = new TranslateReader(I2PAppContext.getGlobalContext(),
"net.i2p.router.web.messages",
fio);
new FileInputStream(file));
int c;
while ((c = r.read()) >= 0) {
System.out.print((char)c);