From 76a966d422ff271ced1fbacfb9a3dfaadf47b294 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 13 Sep 2012 14:02:06 +0200 Subject: [PATCH] Handle spurious wakeups correctly. --- .../sone/freenet/wot/WebOfTrustConnector.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 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 531275d..53a45b1 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -399,14 +399,19 @@ public class WebOfTrustConnector { }; pluginConnector.addConnectorListener(WOT_PLUGIN_NAME, identifier, connectorListener); synchronized (reply) { - pluginConnector.sendRequest(WOT_PLUGIN_NAME, identifier, fields, data); try { - reply.wait(); - } catch (InterruptedException ie1) { - logger.log(Level.WARNING, String.format("Got interrupted while waiting for reply on %s.", fields.get("Message")), ie1); + pluginConnector.sendRequest(WOT_PLUGIN_NAME, identifier, fields, data); + while (reply.getFields() == null) { + try { + reply.wait(); + } catch (InterruptedException ie1) { + logger.log(Level.WARNING, String.format("Got interrupted while waiting for reply on %s.", fields.get("Message")), ie1); + } + } + } finally { + pluginConnector.removeConnectorListener(WOT_PLUGIN_NAME, identifier, connectorListener); } } - pluginConnector.removeConnectorListener(WOT_PLUGIN_NAME, identifier, connectorListener); logger.log(Level.FINEST, String.format("Received FCP Response for %s: %s", fields.get("Message"), (reply.getFields() != null) ? reply.getFields().get("Message") : null)); if ((reply.getFields() == null) || "Error".equals(reply.getFields().get("Message"))) { throw new PluginException("Could not perform request for " + fields.get("Message")); -- 2.7.4