From 449e95ab1c2e1935918daa39d75252551b730d5a Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Sat, 13 Jun 2009 03:50:52 +0000 Subject: [PATCH] BATCH-1289: Add null-check to CoreNamespaceUtils.rangeArrayEditorAlreadyDefined() for a CustomEditorConfigurer with no customEditors property. --- .../configuration/xml/CoreNamespaceUtils.java | 21 +++++++++++-------- .../JobParserParentAttributeTests-context.xml | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java index f2edf0900..e9d40c8fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/CoreNamespaceUtils.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml; import java.util.Map; import java.util.Set; +import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.support.AbstractBeanDefinition; @@ -97,16 +98,18 @@ public class CoreNamespaceUtils { for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition bd = registry.getBeanDefinition(beanName); if (CUSTOM_EDITOR_CONFIGURER_CLASS_NAME.equals(bd.getBeanClassName())) { - Map editors = (Map) bd.getPropertyValues().getPropertyValue("customEditors").getValue(); - for (Map.Entry entry : (Set) editors.entrySet()) { - if (entry.getKey() instanceof TypedStringValue) { - if (RANGE_ARRAY_CLASS_NAME.equals(((TypedStringValue) entry.getKey()).getValue())) { - return true; + PropertyValue pv = bd.getPropertyValues().getPropertyValue("customEditors"); + if (pv != null) { + for (Map.Entry entry : (Set) ((Map) pv.getValue()).entrySet()) { + if (entry.getKey() instanceof TypedStringValue) { + if (RANGE_ARRAY_CLASS_NAME.equals(((TypedStringValue) entry.getKey()).getValue())) { + return true; + } } - } - else if (entry.getKey() instanceof String) { - if (RANGE_ARRAY_CLASS_NAME.equals((String) entry.getKey())) { - return true; + else if (entry.getKey() instanceof String) { + if (RANGE_ARRAY_CLASS_NAME.equals((String) entry.getKey())) { + return true; + } } } } diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml index b21a9f156..712d95555 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/xml/JobParserParentAttributeTests-context.xml @@ -4,6 +4,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + + +