From: David ‘Bombe’ Roden Date: Thu, 13 Sep 2012 12:02:06 +0000 (+0200) Subject: Handle spurious wakeups correctly. X-Git-Tag: 0.8.3^2~25 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=76a966d422ff271ced1fbacfb9a3dfaadf47b294;hp=bd6a583451ef8c6e0a5d56bfb617815c403c2295 Handle spurious wakeups correctly. --- 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"));