Android: Close the DataOutputStream when we are finished with it

Task-number: QTBUG-66769
Change-Id: I93c49baa0ccab4f853402d9be675af1c50b2e0c1
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
bb10
Andy Shaw 2018-02-28 10:35:19 +01:00
parent d8b143d4b7
commit ccdcf8c4f2
1 changed files with 7 additions and 1 deletions

View File

@ -677,12 +677,13 @@ public class QtActivityDelegate
final int timeOut = 30000; // ms until we give up on ping and pong
final int maxAttempts = timeOut / napTime;
DataOutputStream outToClient = null;
try {
LocalSocket connectionFromClient = socket.accept();
debugLog("Debug socket accepted");
BufferedReader inFromClient =
new BufferedReader(new InputStreamReader(connectionFromClient.getInputStream()));
DataOutputStream outToClient = new DataOutputStream(connectionFromClient.getOutputStream());
outToClient = new DataOutputStream(connectionFromClient.getOutputStream());
outToClient.writeBytes("" + android.os.Process.myPid());
for (int i = 0; i < maxAttempts; i++) {
@ -704,6 +705,11 @@ public class QtActivityDelegate
} catch (InterruptedException interruptEx) {
wasFailure = true;
Log.e(QtNative.QtTAG,"Can't start debugger" + interruptEx.getMessage());
} finally {
try {
if (outToClient != null)
outToClient.close();
} catch (IOException ignored) { }
}
}