Replace try-with-resources

LocalServerSocket was not AutoCloseable in older Android SDKs.
This commit is contained in:
Romain Vimont
2023-03-31 00:24:01 +02:00
parent cfc9882897
commit f996386b6e

View File

@@ -68,7 +68,8 @@ public final class DesktopConnection implements Closeable {
LocalSocket controlSocket = null; LocalSocket controlSocket = null;
try { try {
if (tunnelForward) { if (tunnelForward) {
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) { 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
@@ -80,6 +81,8 @@ public final class DesktopConnection implements Closeable {
if (control) { if (control) {
controlSocket = localServerSocket.accept(); controlSocket = localServerSocket.accept();
} }
} finally {
localServerSocket.close();
} }
} else { } else {
videoSocket = connect(socketName); videoSocket = connect(socketName);