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;
try {
if (tunnelForward) {
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) {
LocalServerSocket localServerSocket = new LocalServerSocket(socketName);
try {
videoSocket = localServerSocket.accept();
if (sendDummyByte) {
// 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) {
controlSocket = localServerSocket.accept();
}
} finally {
localServerSocket.close();
}
} else {
videoSocket = connect(socketName);