-
Notifications
You must be signed in to change notification settings - Fork 2.4k
ItemStreamSupport component name collision detection #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.0.x
Are you sure you want to change the base?
Conversation
spring-projects#292. Instead of trying to prevent ExecutionContext key collisions using BeanNameAware, this PR throws an exception on update() when a duplicate component name is detected.
This feels really late in the lifecycle to be throwing an error like this. |
Ideally it should be thrown when registering a stream, but when using a ClassifierCompositeItemWriter for example, the delegates usually won't get registered as a stream. It could be checked in the open() but then we need some way to distinguish:
There is another problem with the current implementation as well: the case where you have for example a FlatFileItemWriter and a second MyCustomFlatFileItemWriter with the same name, it currently won't be detected as a name collision. |
@jpraet Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@jpraet Thank you for signing the Contributor License Agreement! |
We've had to deal with a production issue once again caused by this problem of multiple batch components of the same type persisting restart information in the execution context with colliding keys. I feel like something should be done in the spring batch framework to prevent this common pitfall. The issue specified in the reference docs, but it's just a little sidenote in chapter
If nothing is done in the framework itself, I think it can be indicated more clearly as a warning in the docs. And should also be referred to from chapters |
My concern still stands about breaking restartability between versions. I'm also not 100% sure that causing existing jobs to fail automatically because of this is also the ideal solution (if a step that uses a potentially colliding component is configured to not be restartable for example, the user wouldn't care). Since we already call this out in the documentation, I'm wondering if a simple warning log message when it occurs may be enough so that it's clear what is happening when it occurs. |
To update on this, I'm having a conversation right now in BATCH-2575 about a potential breaking change between major versions related to this. If we do that, then it may make more sense to allow for this kind of change. Thoughts there are welcome! |
Yes, if restart compatibility is being broken between 3.x and 4.x, then I think it's best to merge #292 (which is a better solution to this problem than this PR, as it prevents the problem, instead of simply detecting it). |
As far as I know the underlying problem (key collisions in execution context when using multiple batch components of the same type without configuring a name) still exists. #292 resolve this problem (but was not accepted because it's not backwards compatible regarding job restarts). |
Alternative approach for #292.
Instead of trying to prevent ExecutionContext key collisions using
BeanNameAware, this PR throws an exception on update() when a duplicate
component name is detected.