BATCH-1289: Add null-check to CoreNamespaceUtils.rangeArrayEditorAlreadyDefined() for a CustomEditorConfigurer with no customEditors property.

This commit is contained in:
dhgarrette
2009-06-13 03:50:52 +00:00
parent fe2de35349
commit 449e95ab1c
2 changed files with 15 additions and 9 deletions

View File

@@ -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<Map.Entry>) 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.Entry>) ((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;
}
}
}
}

View File

@@ -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">
<!-- Ensure that no error is thrown from CoreNamespaceUtils due to an empty configurer -->
<beans:bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"/>
<beans:import resource="common-context.xml" />
<job id="job1" parent="baseJob">