Use Closer.close() for various resources.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Wed, 1 Sep 2010 17:53:49 +0000 (19:53 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Wed, 1 Sep 2010 17:53:49 +0000 (19:53 +0200)
src/de/todesbaum/util/freenet/fcp2/Connection.java

index 82b4a6b..d8a8b2d 100644 (file)
@@ -216,34 +216,15 @@ public class Connection {
         * Disconnects from the node.
         */
        public void disconnect() {
-               if (nodeWriter != null) {
-                       try {
-                               nodeWriter.close();
-                       } catch (IOException ioe1) {
-                       }
-                       nodeWriter = null;
-               }
-               if (nodeOutputStream != null) {
-                       try {
-                               nodeOutputStream.close();
-                       } catch (IOException ioe1) {
-                       }
-                       nodeOutputStream = null;
-               }
-               if (nodeInputStream != null) {
-                       try {
-                               nodeInputStream.close();
-                       } catch (IOException ioe1) {
-                       }
-                       nodeInputStream = null;
-               }
-               if (nodeSocket != null) {
-                       try {
-                               nodeSocket.close();
-                       } catch (IOException ioe1) {
-                       }
-                       nodeSocket = null;
-               }
+               Closer.close(nodeWriter);
+               nodeWriter = null;
+               Closer.close(nodeOutputStream);
+               nodeOutputStream = null;
+               Closer.close(nodeInputStream);
+               nodeInputStream = null;
+               nodeInputStream = null;
+               Closer.close(nodeSocket);
+               nodeSocket = null;
                synchronized (this) {
                        notify();
                }