From feaefb2cecf0ca30b7d94e126ca0384435546c08 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 3 Nov 2010 05:59:44 +0100 Subject: [PATCH] Fix timeout. --- .../net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index 0a6369f..7127e8f 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -315,8 +315,13 @@ public class WebOfTrustConnector implements ConnectorListener { synchronized (reply) { pluginConnector.sendRequest(WOT_PLUGIN_NAME, PLUGIN_CONNECTION_IDENTIFIER, fields, data); try { - reply.wait(60000); - throw new PluginException("Timeout waiting for " + targetMessages[0] + "!"); + long now = System.currentTimeMillis(); + while ((reply.getFields() == null) && ((System.currentTimeMillis() - now) < 60000)) { + reply.wait(60000 - (System.currentTimeMillis() - now)); + } + if (reply.getFields() == null) { + throw new PluginException("Timeout waiting for " + targetMessages[0] + "!"); + } } catch (InterruptedException ie1) { logger.log(Level.WARNING, "Got interrupted while waiting for reply on " + targetMessages[0] + ".", ie1); } -- 2.7.4