Let the FCP client implement the Closeable interface.
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / highlevel / FcpClient.java
index dee33c3..d090d64 100644 (file)
@@ -18,6 +18,7 @@
 
 package net.pterodactylus.fcp.highlevel;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetAddress;
@@ -78,7 +79,7 @@ import net.pterodactylus.util.thread.ObjectWrapper;
  *
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  */
-public class FcpClient {
+public class FcpClient implements Closeable {
 
        /** Object used for synchronization. */
        private final Object syncObject = new Object();
@@ -336,7 +337,7 @@ public class FcpClient {
                                if (!getFailed.getIdentifier().equals(identifier)) {
                                        return;
                                }
-                               if (getFailed.getCode() == 27) {
+                               if ((getFailed.getCode() == 27) || (getFailed.getCode() == 24)) {
                                        /* redirect! */
                                        String newUri = getFailed.getRedirectURI();
                                        getResult.realUri(newUri);
@@ -382,6 +383,14 @@ public class FcpClient {
        }
 
        /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void close() {
+               disconnect();
+       }
+
+       /**
         * Returns whether this client is currently connected.
         *
         * @return {@code true} if the client is currently connected, {@code false}
@@ -844,6 +853,7 @@ public class FcpClient {
                        /**
                         * {@inheritDoc}
                         */
+                       @Override
                        public boolean filterObject(Request request) {
                                return request instanceof GetRequest;
                        }
@@ -869,6 +879,7 @@ public class FcpClient {
                        /**
                         * {@inheritDoc}
                         */
+                       @Override
                        public boolean filterObject(Request request) {
                                return request instanceof PutRequest;
                        }