@ -97,43 +97,40 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
@@ -97,43 +97,40 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
if ( result . getValue ( ) = = null & & isAutoGrowNullReferences & &
nextChildIs ( Indexer . class , PropertyOrFieldReference . class ) ) {
TypeDescriptor resultDescriptor = result . getTypeDescriptor ( ) ;
// Creating lists and maps
if ( ( resultDescriptor . getType ( ) . equals ( List . class ) | | resultDescriptor . getType ( ) . equals ( Map . class ) ) ) {
// Create a new collection or map ready for the indexer
if ( resultDescriptor . getType ( ) . equals ( List . class ) ) {
try {
if ( isWritableProperty ( this . name , contextObject , evalContext ) ) {
List < ? > newList = ArrayList . class . newInstance ( ) ;
writeProperty ( contextObject , evalContext , this . name , newList ) ;
result = readProperty ( contextObject , evalContext , this . name ) ;
}
}
catch ( InstantiationException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_LIST_FOR_INDEXING ) ;
}
catch ( IllegalAccessException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_LIST_FOR_INDEXING ) ;
// Create a new collection or map ready for the indexer
if ( List . class . equals ( resultDescriptor . getType ( ) ) ) {
try {
if ( isWritableProperty ( this . name , contextObject , evalContext ) ) {
List < ? > newList = ArrayList . class . newInstance ( ) ;
writeProperty ( contextObject , evalContext , this . name , newList ) ;
result = readProperty ( contextObject , evalContext , this . name ) ;
}
}
els e {
try {
if ( isWritableProperty ( this . name , contextObject , evalContext ) ) {
Map < ? , ? > newMap = HashMap . class . newInstance ( ) ;
writeProperty ( contextObject , evalContext , this . name , newMap ) ;
result = readProperty ( contextObject , evalContext , this . name ) ;
}
}
catch ( InstantiationException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_MAP_FOR_INDEXING ) ;
}
catch ( IllegalAccessException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_MAP_FOR_INDEXING ) ;
catch ( InstantiationException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_LIST_FOR_INDEXING ) ;
}
catch ( IllegalAccessException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_LIST_FOR_INDEXING ) ;
}
}
else if ( Map . class . equals ( resultDescriptor . getType ( ) ) ) {
try {
if ( isWritableProperty ( this . name , contextObject , evalContext ) ) {
Map < ? , ? > newMap = HashMap . class . newInstance ( ) ;
writeProperty ( contextObject , evalContext , this . name , newMap ) ;
result = readProperty ( contextObject , evalContext , this . name ) ;
}
}
catch ( InstantiationException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_MAP_FOR_INDEXING ) ;
}
catch ( IllegalAccessException ex ) {
throw new SpelEvaluationException ( getStartPosition ( ) , ex ,
SpelMessage . UNABLE_TO_CREATE_MAP_FOR_INDEXING ) ;
}
}
else {
// 'simple' object