From c9ec9e11c6a0d3ed2c5ca970f2d7488b28a9128f Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Thu, 30 Apr 2009 10:41:06 +0000 Subject: [PATCH] Fixes programming errors detected by FindBugs. --- .../protocol/icq/ContactGroupIcqImpl.java | 25 +++++++++++++------ ...OperationSetPersistentPresenceIcqImpl.java | 13 +++++++--- .../plugin/sshaccregwizz/FirstWizardPage.java | 7 +++--- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java index a2b38cc88..cb2c94a19 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java @@ -12,7 +12,7 @@ import net.kano.joustsim.oscar.oscar.service.ssi.*; /** - * The ICQ implementation of the ContactGroup interface. Intances of this class + * The ICQ implementation of the ContactGroup interface. Instances of this class * (contrary to RootContactGroupIcqImpl) may only contain buddies * and cannot have sub groups. Note that instances of this class only use the * corresponding joust sim source group for reading their names and only @@ -33,7 +33,7 @@ public class ContactGroupIcqImpl * strings in the left column because screen names in AIM/ICQ are not case * sensitive. */ - private Map buddies + private final Map buddies = new Hashtable(); private boolean isResolved = false; @@ -71,7 +71,7 @@ public class ContactGroupIcqImpl * to directly compare ( == ) instances of buddies we've stored and others * that are returned by the framework. *

- * @param joustSimGroup the JoustSIM Group correspoinding to the group + * @param joustSimGroup the JoustSIM Group corresponding to the group * @param groupMembers the group members that we should add to the group. * @param ssclCallback a callback to the server stored contact list * we're creating. @@ -153,16 +153,25 @@ void addContact(ContactIcqImpl contact) */ void removeContact(ContactIcqImpl contact) { - buddies.remove(contact); + for (Iterator> buddyIter + = buddies.entrySet().iterator(); + buddyIter.hasNext();) + { + if (buddyIter.next().getKey().equals(contact)) + { + buddyIter.remove(); + break; + } + } } /** * Returns an Iterator over all contacts, member of this * ContactGroup. - * + * * @return a java.util.Iterator over all contacts inside this - * ContactGroup. In case the group doesn't contain any - * memebers it will return an empty iterator. + * ContactGroup. In case the group doesn't contain any + * members it will return an empty iterator. */ public Iterator contacts() { @@ -368,7 +377,7 @@ int findContactIndex(Contact contact) /** - * Returns the icq contact encapsulating with the spcieified screen name or + * Returns the icq contact encapsulating with the specified screen name or * null if no such contact was found. * * @param screenName the screenName (or icq UIN) for the contact we're diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java index 3fca252c6..a1e13c53d 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java @@ -1657,9 +1657,16 @@ public boolean authorizationRequired(Screenname screenname, Group parentGroup) ((ContactGroupIcqImpl)parent).removeContact(srcContact); theAwaitingAuthorizationGroup.addContact(srcContact); - Object lock = new Object(); - synchronized(lock){ - try{ lock.wait(500); }catch(Exception e){} + try + { + Thread.sleep(500); + } + catch (InterruptedException ex) + { + /* + * I don't know why the exception is ignored, I just fixed + * an incorrect use of Object.wait(long). + */ } fireSubscriptionMovedEvent(srcContact, diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java index 98db15d82..7419c5e43 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java @@ -14,6 +14,7 @@ import java.awt.*; import java.awt.event.*; + import javax.swing.*; import javax.swing.event.*; @@ -243,15 +244,15 @@ public void actionPerformed(ActionEvent event) /** * Fills the Account ID, Identity File and Known Hosts File fields in this - * panel with the data comming from the given protocolProvider. + * panel with the data coming from the given protocolProvider. * * @param protocolProvider The ProtocolProviderService to load the * data from. */ public void loadAccount(ProtocolProviderService protocolProvider) { - ProtocolProviderFactorySSH protocolProviderSSH = - (ProtocolProviderFactorySSH)protocolProvider; + if (!(protocolProvider instanceof ProtocolProviderServiceSSHImpl)) + throw new ClassCastException("protocolProvider"); AccountID accountID = protocolProvider.getAccountID();