spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

IllegalArgumentException thrown from FlatFileItemReader where IllegalState would be more appropriate [BATCH-1337]

Open spring-projects-issues opened this issue 16 years ago • 5 comments

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

spring-projects-issues avatar Jul 14 '09 04:07 spring-projects-issues

Dave Syer commented

Agree. And the problem is fairly ubiquitous in afterPropertiesSet() methods. Maybe the change can be scripted?

spring-projects-issues avatar Jul 15 '09 17:07 spring-projects-issues

Robert Kasanicky commented

Maybe we should switch to using @Required on setters?

spring-projects-issues avatar Sep 13 '09 04:09 spring-projects-issues

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.

spring-projects-issues avatar Sep 13 '09 05:09 spring-projects-issues

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!

spring-projects-issues avatar Nov 21 '18 12:11 spring-projects-issues

Hi, I opened PR #4055 to address this issue.

danilopiazza avatar Feb 07 '22 08:02 danilopiazza