The changes made with #4855 ignore the names of the discovered Jobs:
|
@Override |
|
public void afterSingletonsInstantiated() { |
|
Map<String, Job> jobBeans = this.applicationContext.getBeansOfType(Job.class); |
|
this.map.putAll(jobBeans); |
|
} |
We see that the bean names are used instead of
Job#getName().
This should probably be changed to something like this:
@Override
public void afterSingletonsInstantiated() {
this.applicationContext.getBeansOfType(Job.class).values().forEach(this::register);
}
Since register() throws a checked exception, the exact logic may need to be changed a bit.
My workaround:
@Bean
MapJobRegistry jobRegistry(ObjectProvider<Job> jobs) {
return new MapJobRegistry() {
// Workaround for https://github.com/spring-projects/spring-batch/issues/5122
@Override
public void afterSingletonsInstantiated() {
for (Job job : jobs) {
try {
register(job);
} catch (DuplicateJobException e) {
throw new IllegalStateException(e);
}
}
}
};
}
The changes made with #4855 ignore the names of the discovered Jobs:
spring-batch/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java
Lines 63 to 67 in fa73e01
We see that the bean names are used instead of
Job#getName().This should probably be changed to something like this:
Since
register()throws a checked exception, the exact logic may need to be changed a bit.My workaround: