You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by be...@apache.org on 2012/11/21 12:04:43 UTC

svn commit: r1412056 - /mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java

Author: berndf
Date: Wed Nov 21 11:04:42 2012
New Revision: 1412056

URL: http://svn.apache.org/viewvc?rev=1412056&view=rev
Log:
VYSPER-335: check for NPEs in DefaultResourceRegistry

Modified:
    mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java?rev=1412056&r1=1412055&r2=1412056&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/DefaultResourceRegistry.java Wed Nov 21 11:04:42 2012
@@ -136,7 +136,7 @@ public class DefaultResourceRegistry imp
      * @param resourceId
      */
     public boolean unbindResource(String resourceId) {
-        boolean noResourceRemainsForSession = false;
+        boolean noResourceRemainsForSession;
         synchronized (boundResources) {
             synchronized (entityResources) {
                 synchronized (sessionResources) {
@@ -144,9 +144,12 @@ public class DefaultResourceRegistry imp
 
                     // remove from entity's list of resources
                     List<String> resourceListForEntity = getResourceList(sessionContext.getInitiatingEntity());
-                    resourceListForEntity.remove(resourceId);
-                    if (resourceListForEntity.isEmpty())
-                        entityResources.remove(sessionContext.getInitiatingEntity());
+                    if (resourceListForEntity != null) {
+                        resourceListForEntity.remove(resourceId);
+                        if (resourceListForEntity.isEmpty()) {
+                            entityResources.remove(sessionContext.getInitiatingEntity());
+                        }
+                    }
 
                     // remove from session's list of resources
                     List<String> resourceListForSession = sessionResources.get(sessionContext);
@@ -411,6 +414,8 @@ public class DefaultResourceRegistry imp
     public List<String> getInterestedResources(Entity entity) {
         List<String> resources = getResourceList(entity);
         List<String> result = new ArrayList<String>();
+        if (resources == null) return result;
+        
         for (String resource : resources) {
             ResourceState resourceState = getResourceState(resource);
             if (ResourceState.isInterested(resourceState))
@@ -426,6 +431,8 @@ public class DefaultResourceRegistry imp
     public List<String> getAvailableResources(Entity entity) {
         List<String> resources = getResourceList(entity);
         List<String> result = new ArrayList<String>();
+        if (resources == null) return result;
+
         for (String resource : resources) {
             ResourceState resourceState = getResourceState(resource);
             if (resourceState == AVAILABLE || resourceState == AVAILABLE_INTERESTED) {