spring-batch
spring-batch copied to clipboard
IllegalArgumentException thrown from FlatFileItemReader where IllegalState would be more appropriate [BATCH-1337]
Iwein Fuld opened BATCH-1337 and commented
public void afterPropertiesSet() throws Exception {
Assert.notNull(lineMapper, "LineMapper is required");
}
Should use Assert.state instead imo.
Affects: 2.0.1
Dave Syer commented
Agree. And the problem is fairly ubiquitous in afterPropertiesSet() methods. Maybe the change can be scripted?
Dave Syer commented
I don't like @Required, and I don't think it's appropriate for framework classes, since it requires the user to add a bean post processor for it to work. InitializingBean is better for my money.
Mahmoud Ben Hassine commented
@Iwein Fuld I also agree. However, there are some places in the code base that use Assert.state (like AbstractJob and AbstractStep) while other places use Assert.notNull as you mentioned. It would be great to make this consistent across the whole code base and not only for the FlatFileItemReader. Feel free to open a PR if you want, contributions are welcome!
Hi, I opened PR #4055 to address this issue.