You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pa...@apache.org on 2018/01/25 14:01:44 UTC

svn commit: r1822204 - in /myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator: BeanValidator.java DoubleRangeValidator.java LengthValidator.java LongRangeValidator.java MethodExpressionValidator.java RegexValidator.java

Author: paulnicolucci
Date: Thu Jan 25 14:01:44 2018
New Revision: 1822204

URL: http://svn.apache.org/viewvc?rev=1822204&view=rev
Log:
MYFACES-4194: throw NPE in validators - restore/save state methods if FacesContext is null

Modified:
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/BeanValidator.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LengthValidator.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LongRangeValidator.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java
    myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/RegexValidator.java

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/BeanValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/BeanValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/BeanValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/BeanValidator.java Thu Jan 25 14:01:44 2018
@@ -425,6 +425,11 @@ public class BeanValidator implements Va
     @Override
     public Object saveState(final FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (!initialStateMarked())
         {
            //Full state saving.
@@ -448,6 +453,11 @@ public class BeanValidator implements Va
     @Override
     public void restoreState(final FacesContext context, final Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (state != null)
         {
             this.validationGroups = (String) state;

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/DoubleRangeValidator.java Thu Jan 25 14:01:44 2018
@@ -183,6 +183,11 @@ public class DoubleRangeValidator
     // RESTORE/SAVE STATE
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (!initialStateMarked())
         {
             Object values[] = new Object[2];
@@ -196,6 +201,11 @@ public class DoubleRangeValidator
     public void restoreState(FacesContext context,
                              Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+        
         if (state != null)
         {
             Object values[] = (Object[])state;

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LengthValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LengthValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LengthValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LengthValidator.java Thu Jan 25 14:01:44 2018
@@ -164,6 +164,11 @@ public class LengthValidator
     // RESTORE & SAVE STATE
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (!initialStateMarked())
         {
             Object values[] = new Object[2];
@@ -177,6 +182,11 @@ public class LengthValidator
     public void restoreState(FacesContext context,
                              Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (state != null)
         {
             Object values[] = (Object[])state;

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LongRangeValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LongRangeValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LongRangeValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/LongRangeValidator.java Thu Jan 25 14:01:44 2018
@@ -193,6 +193,11 @@ public class LongRangeValidator
     // RESTORE & SAVE STATE
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (!initialStateMarked())
         {
             Object values[] = new Object[2];
@@ -206,6 +211,11 @@ public class LongRangeValidator
     public void restoreState(FacesContext context,
                              Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (state != null)
         {
             Object values[] = (Object[])state;

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/MethodExpressionValidator.java Thu Jan 25 14:01:44 2018
@@ -100,11 +100,21 @@ public class MethodExpressionValidator i
 
     public void restoreState(FacesContext context, Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         methodExpression = (MethodExpression)state;
     }
 
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         return methodExpression;
     }
 

Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/RegexValidator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/RegexValidator.java?rev=1822204&r1=1822203&r2=1822204&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/RegexValidator.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/validator/RegexValidator.java Thu Jan 25 14:01:44 2018
@@ -164,6 +164,11 @@ public class RegexValidator implements V
     /** {@inheritDoc} */
     public Object saveState(FacesContext context)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (!initialStateMarked())
         {
             return pattern;
@@ -174,6 +179,11 @@ public class RegexValidator implements V
     /** {@inheritDoc} */
     public void restoreState(FacesContext context, Object state)
     {
+        if (context == null)
+        {
+            throw new NullPointerException("context");
+        }
+
         if (state != null)
         {
             //Since pattern is required, if state is null