forked from I2P_Developers/i2p.i2p
Cleanups: Close resources via try-finally
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -64,19 +64,21 @@ public class MultiRouter {
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
Scanner scan = new Scanner(args[0]);
|
||||
if (!scan.hasNextInt()) {
|
||||
usage();
|
||||
scan.close();
|
||||
return;
|
||||
Scanner scan = null;
|
||||
try {
|
||||
scan = new Scanner(args[0]);
|
||||
if (!scan.hasNextInt()) {
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
nbrRouters = scan.nextInt();
|
||||
if (nbrRouters < 0) {
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
if (scan != null) scan.close();
|
||||
}
|
||||
nbrRouters = scan.nextInt();
|
||||
if (nbrRouters < 0) {
|
||||
usage();
|
||||
scan.close();
|
||||
return;
|
||||
}
|
||||
scan.close();
|
||||
|
||||
_out = System.out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user