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

When an parameter with empty value is provided, `DefaultJobParametersConverter` fails with not user-friendly message.

Open hanqyu opened this issue 1 year ago • 0 comments

Please do a quick search on Github issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description If the job parameter given like

param1= ,param2=foo

org.springframework.batch.core.converter.DefaultJobParametersConverter#parseValue fails with ArrayIndexOutOfBoundsException.

Environment Spring Batch 5.1.0

Steps to reproduce pass args to the runner like

param1= ,param2=foo

Expected behavior If the intention is not to allow empty values, the error message should be more user-friendly. If not, the system should create and bind a JobParameter even for empty values.

Minimal Complete Reproducible example replacing with attachment of stacktrace

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at org.springframework.batch.core.converter.DefaultJobParametersConverter.parseValue(DefaultJobParametersConverter.java:172)
	at org.springframework.batch.core.converter.DefaultJobParametersConverter.decode(DefaultJobParametersConverter.java:158)
	at org.springframework.batch.core.converter.DefaultJobParametersConverter.getJobParameters(DefaultJobParametersConverter.java:104)
	at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.launchJobFromProperties(JobLauncherApplicationRunner.java:173)
	at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:169)
	at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:164)

hanqyu avatar Jun 19 '24 05:06 hanqyu