Author: tchemit Date: 2010-05-10 23:35:48 +0200 (Mon, 10 May 2010) New Revision: 1845 Url: http://nuiton.org/repositories/revision/nuiton-utils/1845 Log: fix NPE in binder when collection is null Modified: trunk/src/main/java/org/nuiton/util/beans/Binder.java Modified: trunk/src/main/java/org/nuiton/util/beans/Binder.java =================================================================== --- trunk/src/main/java/org/nuiton/util/beans/Binder.java 2010-05-10 12:52:12 UTC (rev 1844) +++ trunk/src/main/java/org/nuiton/util/beans/Binder.java 2010-05-10 21:35:48 UTC (rev 1845) @@ -109,7 +109,7 @@ /** * Obtains the type of the source bean. - * + * * @return the type of the source bean */ public Class<I> getSourceType() { @@ -322,9 +322,13 @@ protected Object bindCollection(String sourceProperty, Object read) throws IllegalAccessException, InstantiationException { + if (read == null) { + return null; + } + Binder binder = model.getBinder(sourceProperty); - Collection result; + Collection result = null; if (read instanceof Set<?>) { result = new HashSet(); @@ -334,8 +338,6 @@ result = new ArrayList(); } - result = new ArrayList<Object>(); - for (Object o : (Collection<?>) read) { Object r = bind(binder, o); result.add(r);
participants (1)
-
tchemit@users.nuiton.org