You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/02/05 10:11:14 UTC

svn commit: r906858 - in /sling/trunk/bundles/api/src/main/java/org/apache/sling/api: resource/ValueMap.java wrappers/ValueMapDecorator.java

Author: cziegeler
Date: Fri Feb  5 09:11:13 2010
New Revision: 906858

URL: http://svn.apache.org/viewvc?rev=906858&view=rev
Log:
SLING-1352 : ValueMapDecorator#get(String name, T defaultValue) throws NPE if default value is null

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java?rev=906858&r1=906857&r2=906858&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java Fri Feb  5 09:11:13 2010
@@ -54,7 +54,7 @@
      * @param defaultValue The default value to use if the named property does
      *            not exist or cannot be converted to the requested type. The
      *            default value is also used to define the type to convert the
-     *            value to. If this is <code>null</code> any existing propert is
+     *            value to. If this is <code>null</code> any existing property is
      *            not converted.
      * @return Return named value converted to type T or the default value if
      *         non existing or can't be converted.

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java?rev=906858&r1=906857&r2=906858&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java (original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/wrappers/ValueMapDecorator.java Fri Feb  5 09:11:13 2010
@@ -113,6 +113,9 @@
      */
     @SuppressWarnings("unchecked")
     public <T> T get(String name, T defaultValue) {
+        if ( defaultValue == null ) {
+            return (T)get(name);
+        }
         T value = get(name, (Class<T>) defaultValue.getClass());
         return value == null ? defaultValue : value;
     }