From f996386b6e1eee8c28fc5afc64a70d37acb8a490 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 31 Mar 2023 00:24:01 +0200 Subject: [PATCH] Replace try-with-resources LocalServerSocket was not AutoCloseable in older Android SDKs. --- .../main/java/com/genymobile/scrcpy/DesktopConnection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java index 4bfff726..053e2b51 100644 --- a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java +++ b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java @@ -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);