Replace try with try-with-resources
Update existing try/finally/close blocks to use "try with resources" See gh-9781
This commit is contained in:
parent
798fe5ed53
commit
d16af43664
|
|
@ -170,10 +170,9 @@ public class TunnelClient implements SmartInitializingSingleton {
|
|||
|
||||
private void handleConnection(SocketChannel socketChannel) throws Exception {
|
||||
Closeable closeable = new SocketCloseable(socketChannel);
|
||||
WritableByteChannel outputChannel = TunnelClient.this.tunnelConnection
|
||||
.open(socketChannel, closeable);
|
||||
TunnelClient.this.listeners.fireOpenEvent(socketChannel);
|
||||
try {
|
||||
try (WritableByteChannel outputChannel = TunnelClient.this.tunnelConnection
|
||||
.open(socketChannel, closeable)) {
|
||||
logger.trace("Accepted connection to tunnel client from "
|
||||
+ socketChannel.socket().getRemoteSocketAddress());
|
||||
while (true) {
|
||||
|
|
@ -189,9 +188,6 @@ public class TunnelClient implements SmartInitializingSingleton {
|
|||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
outputChannel.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void stopAcceptingConnections() {
|
||||
|
|
|
|||
|
|
@ -186,8 +186,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
|||
|
||||
private long getNestedLibraryTime(File file) {
|
||||
try {
|
||||
JarFile jarFile = new JarFile(file);
|
||||
try {
|
||||
try (JarFile jarFile = new JarFile(file)) {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
|
|
@ -196,9 +195,6 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
|||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Ignore and just use the source file timestamp
|
||||
|
|
@ -381,13 +377,9 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
|||
private long size;
|
||||
|
||||
CrcAndSize(File file) throws IOException {
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
try {
|
||||
try (FileInputStream inputStream = new FileInputStream(file)) {
|
||||
load(inputStream);
|
||||
}
|
||||
finally {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
CrcAndSize(InputStream inputStream) throws IOException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue