Title: [2125] trunk: Fix NPE in AttributeMapper.shouldLookForSingleValueConverter if parameters fieldName and definedIn are null.
Revision
2125
Author
joehni
Date
2013-09-24 19:12:01 -0500 (Tue, 24 Sep 2013)

Log Message

Fix NPE in AttributeMapper.shouldLookForSingleValueConverter if parameters fieldName and definedIn are null.

Modified Paths

Diff

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/mapper/AttributeMapper.java (2124 => 2125)


--- trunk/xstream/src/java/com/thoughtworks/xstream/mapper/AttributeMapper.java	2013-09-21 21:18:26 UTC (rev 2124)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/mapper/AttributeMapper.java	2013-09-25 00:12:01 UTC (rev 2125)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2006 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2009, 2010 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2013 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -102,8 +102,15 @@
     }
 
     public boolean shouldLookForSingleValueConverter(String fieldName, Class type, Class definedIn) {
-        Field field = reflectionProvider.getField(definedIn, fieldName);
-        return fieldToUseAsAttribute.contains(field) || fieldNameToTypeMap.get(fieldName) == type || typeSet.contains(type);
+        if (typeSet.contains(type)) {
+            return true;
+        } else if (fieldNameToTypeMap.get(fieldName) == type) {
+            return true;
+        } else if (fieldName != null && definedIn != null) {
+            Field field = reflectionProvider.getField(definedIn, fieldName);
+            return fieldToUseAsAttribute.contains(field);
+        }
+        return false;
     }
 
     /**

Modified: trunk/xstream-distribution/src/content/changes.html (2124 => 2125)


--- trunk/xstream-distribution/src/content/changes.html	2013-09-21 21:18:26 UTC (rev 2124)
+++ trunk/xstream-distribution/src/content/changes.html	2013-09-25 00:12:01 UTC (rev 2125)
@@ -85,6 +85,7 @@
     	these converters and an example in the acceptance tests (AliasTest).</li>
     	<li>JIRA:XSTR-742: Register CompositeClassLoader in Java 7 as parallel capable.</li>
     	<li>JIRA:XSTR-743: Support proxy collections of Hibernate Envers.</li>
+    	<li>Fix NPE in AttributeMapper.shouldLookForSingleValueConverter if parameters fieldName and definedIn are null.</li>
     </ul>
 
     <h2>API changes</h2>

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to