From a86dfc2674ca9810d2492bc6137ac824aa655682 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 10 Oct 2014 16:55:34 +0200 Subject: [PATCH] Add additional logging to find out why getMessage() returns null. --- src/main/java/de/todesbaum/util/freenet/fcp2/Client.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/todesbaum/util/freenet/fcp2/Client.java b/src/main/java/de/todesbaum/util/freenet/fcp2/Client.java index 8e819d3..8f2a558 100644 --- a/src/main/java/de/todesbaum/util/freenet/fcp2/Client.java +++ b/src/main/java/de/todesbaum/util/freenet/fcp2/Client.java @@ -18,9 +18,12 @@ 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; } -- 2.7.4