You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2007/03/23 08:29:01 UTC

svn commit: r521607 - /myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java

Author: matzew
Date: Fri Mar 23 00:29:01 2007
New Revision: 521607

URL: http://svn.apache.org/viewvc?view=rev&rev=521607
Log:
MYFACES-1576 - PropertyResolver.getType() should check arguments
thx to Paul McMahan

Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java?view=diff&rev=521607&r1=521606&r2=521607
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/el/PropertyResolverImpl.java Fri Mar 23 00:29:01 2007
@@ -15,6 +15,8 @@
  */
 package org.apache.myfaces.el;
 
+import java.util.List;
+
 import javax.el.ELContext;
 import javax.el.ELException;
 import javax.el.ELResolver;
@@ -101,6 +103,9 @@
     @Override
     public Class getType(final Object base, final Object property)
     {
+        if (base == null || property == null)
+            throw new PropertyNotFoundException();
+        
         return invokeResolver(new ResolverInvoker<Class>(base, property)
         {
             public Class invoke(ELResolver resolver, ELContext context)
@@ -113,9 +118,22 @@
     @Override
     public Class getType(Object base, int index)
     {
+        if (base == null)
+            throw new PropertyNotFoundException();
+        
+        if (base instanceof Object[]) {
+            if (index < 0 || index>=((Object[])base).length) {
+                throw new PropertyNotFoundException();
+            }
+        } else if (base instanceof List) {
+            if (index < 0 || index>=((List)base).size()) {
+                throw new PropertyNotFoundException();
+            }
+        }
+        
         return getType(base, new Integer(index));
     }
-
+    
     // ~ Internal Helper Methods
     // ------------------------------------------------
 
@@ -173,4 +191,4 @@
             return "base: '" + _base + "' property/index: '" + _property + "'";
         }
     }
-}
\ No newline at end of file
+}