Use try-with-resources

Replace an explicit try-finally by a try-with-resources block.
This commit is contained in:
Romain Vimont 2023-01-27 21:59:26 +01:00
parent 4315be1648
commit b22810b17c

View file

@ -61,8 +61,7 @@ public final class DesktopConnection implements Closeable {
LocalSocket videoSocket;
LocalSocket controlSocket = null;
if (tunnelForward) {
LocalServerSocket localServerSocket = new LocalServerSocket(socketName);
try {
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) {
videoSocket = localServerSocket.accept();
if (sendDummyByte) {
// send one byte so the client may read() to detect a connection error
@ -76,8 +75,6 @@ public final class DesktopConnection implements Closeable {
throw e;
}
}
} finally {
localServerSocket.close();
}
} else {
videoSocket = connect(socketName);