OSDN Git Service

Fix warning in Android side.
authorMathewka <mathewka@git.osdn.jp>
Sat, 9 Jan 2016 20:02:36 +0000 (05:02 +0900)
committerMathewka <mathewka@git.osdn.jp>
Sat, 9 Jan 2016 20:02:36 +0000 (05:02 +0900)
SyncerClient/src/org/upsuper/playlistsyncer/client/SyncerClient.java

index 0ddd582..6c63af4 100644 (file)
@@ -58,8 +58,9 @@ public class SyncerClient implements Runnable {
 
        @Override
        public void run() {
+               Socket socket = null;
                try {
-                       Socket socket = new Socket(dstAddress, dstPort);
+                       socket = new Socket(dstAddress, dstPort);
                        in = new BufferedInputStream(socket.getInputStream());
                        out = new PrintStream(socket.getOutputStream());
 
@@ -74,6 +75,12 @@ public class SyncerClient implements Runnable {
                        receivePlaylists();
                } catch (IOException e) {
                        listener.onClientError(e);
+               } finally {
+                       if (socket != null) {
+                               try {
+                                       socket.close();
+                               } catch (IOException e) { }
+                       }
                }
        }