Close underlying channels
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 2 Feb 2018 18:36:28 +0000 (19:36 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 2 Feb 2018 18:36:28 +0000 (19:36 +0100)
org.argeo.slc.core/src/org/argeo/slc/core/execution/http/ServiceChannel.java

index 3e6a1ab89cfe40d951b3ac4026cbcd1c97b15214..ef8febd000a1c6f75cf1a865f9420dbce7a3fd33 100644 (file)
@@ -54,14 +54,23 @@ public class ServiceChannel implements AsynchronousByteChannel {
        }
 
        @Override
-       /** NB: it does not close the underlying channels. */
-       public void close() throws IOException {
+       public synchronized void close() throws IOException {
+               try {
+                       in.close();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               try {
+                       out.close();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
                open = false;
                notifyAll();
        }
 
        @Override
-       public boolean isOpen() {
+       public synchronized boolean isOpen() {
                return open;
        }