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:
Emanuel Campolo
2017-07-18 12:04:54 -03:00
committed by Phillip Webb
parent 798fe5ed53
commit d16af43664
2 changed files with 4 additions and 16 deletions

View File

@@ -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() {