diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java index 8cedf3b84..644b3617a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/StepScope.java @@ -144,7 +144,6 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { @SuppressWarnings("rawtypes") @Override public Object get(String name, ObjectFactory objectFactory) { - StepContext context = getContext(); Object scopedObject = context.getAttribute(name); @@ -239,7 +238,8 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered { boolean scoped = name.equals(definition.getScope()); Scopifier scopifier = new Scopifier(registry, name, proxyTargetClass, scoped); scopifier.visitBeanDefinition(definition); - if (scoped) { + + if (scoped && !definition.isAbstract()) { createScopedProxy(beanName, definition, registry, proxyTargetClass); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java index eb8ade51a..5c51a9321 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java @@ -69,6 +69,15 @@ public class StepScopeConfigurationTests { assertEquals("STEP", value.call()); } + @Test + public void testXmlStepScopeWithInheritence() throws Exception { + context = new ClassPathXmlApplicationContext( + "org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInheritence-context.xml"); + StepSynchronizationManager.register(stepExecution); + SimpleHolder value = (SimpleHolder) context.getBean("child"); + assertEquals("STEP", value.call()); + } + @Test public void testStepScopeWithProxyTargetClass() throws Exception { init(StepScopeConfigurationRequiringProxyTargetClass.class); @@ -165,7 +174,7 @@ public class StepScopeConfigurationTests { return value; } } - + public static class Wrapper { private SimpleHolder value; @@ -173,17 +182,17 @@ public class StepScopeConfigurationTests { public Wrapper(SimpleHolder value) { this.value = value; } - + public SimpleHolder getValue() { return value; } - + } @Configuration @EnableBatchProcessing public static class StepScopeConfigurationInjectingProxy { - + @Bean public Wrapper wrapper(SimpleHolder value) { return new Wrapper(value); diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInheritence-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInheritence-context.xml new file mode 100644 index 000000000..4b8506ff6 --- /dev/null +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTestsInheritence-context.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file