You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/11/30 00:23:13 UTC

svn commit: r599625 - /myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java

Author: jwaldman
Date: Thu Nov 29 15:23:03 2007
New Revision: 599625

URL: http://svn.apache.org/viewvc?rev=599625&view=rev
Log:
TRINIDAD-803 NPE in UIXCollection saveStampState()
This is in 1.0.4 and didn't get merged in to 1.2.4 and it should have been.

Modified:
    myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java

Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=599625&r1=599624&r2=599625&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Thu Nov 29 15:23:03 2007
@@ -813,14 +813,14 @@
       for(Map.Entry<String, UIComponent> entry : facetMap.entrySet())
       {
         Object singleFacetState = saveStampState(context, entry.getValue());
+        if ((singleFacetState == null) ||
+            (singleFacetState == Transient.TRUE))
+          continue;
+        
         // Don't bother allocating anything until we have some non-null
         // and non-transient facet state
         if (facetStateIsEmpty)
-        {
-          if ((singleFacetState == null) ||
-              (singleFacetState == Transient.TRUE))
-            continue;
-          
+        {          
           facetStateIsEmpty = false;
           facetState = new Object[facetCount * 2];
         }
@@ -831,11 +831,18 @@
         facetState[base + 1] = singleFacetState;
         i++;
       }
-
+      
       // OK, we had something:  allocate the state array to three
       // entries, and insert the facet state at position 2
       if (!facetStateIsEmpty)
       {
+        // trim the facetState array if necessary
+        if(i < facetCount)
+        {
+          Object[] trimmed = new Object[i*2];
+          System.arraycopy(facetState, 0, trimmed, 0, i*2);
+          facetState = trimmed;
+        }
         state = new Object[3];
         state[2] = facetState;
       }