Use try-with-resources
Replace an explicit try-finally by a try-with-resources block.
This commit is contained in:
@@ -61,8 +61,7 @@ public final class DesktopConnection implements Closeable {
|
|||||||
LocalSocket videoSocket;
|
LocalSocket videoSocket;
|
||||||
LocalSocket controlSocket = null;
|
LocalSocket controlSocket = null;
|
||||||
if (tunnelForward) {
|
if (tunnelForward) {
|
||||||
LocalServerSocket localServerSocket = new LocalServerSocket(socketName);
|
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) {
|
||||||
try {
|
|
||||||
videoSocket = localServerSocket.accept();
|
videoSocket = localServerSocket.accept();
|
||||||
if (sendDummyByte) {
|
if (sendDummyByte) {
|
||||||
// send one byte so the client may read() to detect a connection error
|
// 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;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
localServerSocket.close();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
videoSocket = connect(socketName);
|
videoSocket = connect(socketName);
|
||||||
|
|||||||
Reference in New Issue
Block a user