@@ -43,6 +43,10 @@ protected Object resolveCollection(PropertyTokenizer prop, Object object) {
4343 }
4444
4545 protected Object getCollectionValue (PropertyTokenizer prop , Object collection ) {
46+ if (collection == null ) {
47+ throw new ReflectionException ("Cannot get the value '" + prop .getIndexedName () + "' because the property '"
48+ + prop .getName () + "' is null." );
49+ }
4650 if (collection instanceof Map ) {
4751 return ((Map ) collection ).get (prop .getIndex ());
4852 }
@@ -68,12 +72,16 @@ protected Object getCollectionValue(PropertyTokenizer prop, Object collection) {
6872 } else if (collection instanceof short []) {
6973 return ((short []) collection )[i ];
7074 } else {
71- throw new ReflectionException (
72- "The '" + prop .getName () + "' property of " + collection + " is not a List or Array." );
75+ throw new ReflectionException ("Cannot get the value '" + prop . getIndexedName () + "' because the property '"
76+ + prop .getName () + "' is not Map, List or Array." );
7377 }
7478 }
7579
7680 protected void setCollectionValue (PropertyTokenizer prop , Object collection , Object value ) {
81+ if (collection == null ) {
82+ throw new ReflectionException ("Cannot set the value '" + prop .getIndexedName () + "' because the property '"
83+ + prop .getName () + "' is null." );
84+ }
7785 if (collection instanceof Map ) {
7886 ((Map ) collection ).put (prop .getIndex (), value );
7987 } else {
@@ -99,8 +107,8 @@ protected void setCollectionValue(PropertyTokenizer prop, Object collection, Obj
99107 } else if (collection instanceof short []) {
100108 ((short []) collection )[i ] = (Short ) value ;
101109 } else {
102- throw new ReflectionException (
103- "The '" + prop .getName () + "' property of " + collection + " is not a List or Array." );
110+ throw new ReflectionException ("Cannot set the value '" + prop . getIndexedName () + "' because the property '"
111+ + prop .getName () + "' is not Map, List or Array." );
104112 }
105113 }
106114 }
0 commit comments