Add additional logging to find out why getMessage() returns null.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 10 Oct 2014 14:55:34 +0000 (16:55 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 10 Oct 2014 14:55:34 +0000 (16:55 +0200)
src/main/java/de/todesbaum/util/freenet/fcp2/Client.java

index 8e819d3..8f2a558 100644 (file)
 
 package de.todesbaum.util.freenet.fcp2;
 
+import static java.util.logging.Logger.getLogger;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Logger;
 
 import net.pterodactylus.util.io.StreamCopier.ProgressListener;
 
@@ -33,6 +36,8 @@ import net.pterodactylus.util.io.StreamCopier.ProgressListener;
  */
 public class Client implements ConnectionListener {
 
+       private static final Logger logger = getLogger(Client.class.getName());
+
        /** The connection this client operates on. */
        private final Connection connection;
 
@@ -200,18 +205,23 @@ public class Client implements ConnectionListener {
        public Message readMessage(long maxWaitTime) {
                synchronized (messageQueue) {
                        if (disconnected) {
+                               logger.fine("Disconnected.");
                                return null;
                        }
                        if (messageQueue.size() == 0) {
                                try {
                                        messageQueue.wait(maxWaitTime);
                                } catch (InterruptedException ie1) {
+                                       logger.fine("Interrupted.");
                                }
                        }
                        if (messageQueue.size() > 0) {
-                               return messageQueue.remove(0);
+                               Message message = messageQueue.remove(0);
+                               logger.fine("Got a message: " + message);
+                               return message;
                        }
                }
+               logger.fine("Got no message.");
                return null;
        }