You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by cj...@apache.org on 2010/01/28 13:19:20 UTC

svn commit: r904059 - /myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java

Author: cjhoward
Date: Thu Jan 28 12:19:20 2010
New Revision: 904059

URL: http://svn.apache.org/viewvc?rev=904059&view=rev
Log:
MYFACES-2508 - saveState()/restoreState() need to throw NPEs if args are null.

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=904059&r1=904058&r2=904059&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Thu Jan 28 12:19:20 2010
@@ -1416,6 +1416,11 @@
      */
     public static Object saveAttachedState(FacesContext context, Object attachedObject)
     {
+        if (context == null)
+        {
+            throw new NullPointerException ("context");
+        }
+        
         if (attachedObject == null)
             return null;
         // StateHolder interface should take precedence over
@@ -1506,6 +1511,11 @@
      */
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException ("context");
+        }
+        
         if (initialStateMarked())
         {
             //Delta
@@ -1559,10 +1569,20 @@
     @SuppressWarnings("unchecked")
     public void restoreState(FacesContext context, Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException ("context");
+        }
+        
         if (state == null)
         {
             //Only happens if initialStateMarked return true
-            return;
+            //return;
+            
+            // Commenting the above out because Javadocs say that we need to
+            // throw an NPE here.
+            
+            throw new NullPointerException ("state");
         }
         
         Object values[] = (Object[]) state;