From c33b6aced1514f561e07a956d97c0f58870e2cf5 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Sat, 7 Oct 2006 12:46:32 +0000 Subject: [PATCH] An attempt to fix failing modifications of server stored details. --- ...tionSetServerStoredAccountInfoIcqImpl.java | 74 +++++++++---------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredAccountInfoIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredAccountInfoIcqImpl.java index 84adf505d..6e09d266d 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredAccountInfoIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredAccountInfoIcqImpl.java @@ -167,12 +167,7 @@ public void addDetail(GenericDetail detail) throws IllegalArgumentException, icqProvider.getAimConnection().getInfoService(). sendSnacRequest(new FullInfoCmd(uin, alreadySetDetails, null), responseListener); - synchronized(responseListener.waitingForResponseLock){ - try{ - responseListener.waitingForResponseLock.wait(2000); - } - catch (InterruptedException ex){} - } + responseListener.waitForEvent(5000); if(!responseListener.success) if(responseListener.timeout) @@ -228,12 +223,7 @@ public boolean removeDetail(GenericDetail detail) throws icqProvider.getAimConnection().getInfoService(). sendSnacRequest(new FullInfoCmd(uin, foundValues, removeValues), responseListener); - synchronized(responseListener.waitingForResponseLock){ - try{ - responseListener.waitingForResponseLock.wait(2000);} - catch (InterruptedException ex) - {} - } + responseListener.waitForEvent(5000); if(!responseListener.success && responseListener.timeout) throw new OperationFailedException("Replacing Detail Failed!", @@ -296,12 +286,7 @@ public boolean replaceDetail(GenericDetail currentDetailValue, sendSnacRequest( new FullInfoCmd(uin, alreadySetDetails, null), responseListener); - synchronized(responseListener.waitingForResponseLock){ - try{ - responseListener.waitingForResponseLock.wait(2000); - } - catch (InterruptedException ex){} - } + responseListener.waitForEvent(5000); if(!responseListener.success && responseListener.timeout) throw new OperationFailedException("Replacing Detail Failed!", @@ -330,51 +315,58 @@ private class SuccessResponseListener private boolean timeout = false; - public void handleSent(SnacRequestSentEvent e) + public void handleSent(SnacRequestSentEvent evt) {} public void handleTimeout(SnacRequestTimeoutEvent event) { logger.trace("Timeout!"); - synchronized(this) { - if (ran) return; + synchronized(waitingForResponseLock) + { + if (ran) + return; ran = true; timeout = true; - } - - synchronized(waitingForResponseLock) - { waitingForResponseLock.notifyAll(); } } - public void handleResponse(SnacResponseEvent e) + public void handleResponse(SnacResponseEvent evt) { - synchronized(this) { - if (ran) return; - ran = true; - } - if(e.getSnacCommand() instanceof FullInfoAck) + synchronized(waitingForResponseLock) { - FullInfoAck cmd = (FullInfoAck)e.getSnacCommand();; - if(cmd.isCommandSuccesful()) + if (ran) + return; + ran = true; + if (evt.getSnacCommand() instanceof FullInfoAck) { - success = true; + FullInfoAck cmd = (FullInfoAck) evt.getSnacCommand(); + if (cmd.isCommandSuccesful()) + { + success = true; + } } - } - - synchronized(waitingForResponseLock){ waitingForResponseLock.notifyAll(); } } - public void wait(int milliseconds) + public void waitForEvent(int milliseconds) { - synchronized (this){ - if(ran) return; - this.wait(milliseconds); + synchronized (waitingForResponseLock){ + if(ran) + return; + + try + { + waitingForResponseLock.wait(milliseconds); + } + catch (InterruptedException exc) + { + logger.error("Interrupted while waiting for response." + , exc); + } } } }