Bug description
CommandLineJobOperator.parse() uses String.split("=") without a limit, which splits on every = character. This causes two problems:
- Parameter values containing
= get truncated (e.g. URLs with query strings)
- Parameters without
= throw ArrayIndexOutOfBoundsException
The deprecated CommandLineJobRunner and Spring Boot's JobLauncherApplicationRunner both use StringUtils.splitArrayElementsIntoProperties which correctly splits only on the first =.
Environment
Spring Batch 6.0.x (all versions since CommandLineJobOperator was introduced in 6.0)
Steps to reproduce
Run a job via CommandLineJobOperator with a parameter containing = in the value:
java ... CommandLineJobOperator com.example.MyJobConfig start myJob url=http://example.com?id=123
Expected behavior
The parameter should be parsed as url → http://example.com?id=123.
Current behavior
split("=") produces ["url", "http://example.com?id", "123"], so only http://example.com?id is stored as the value. The rest is lost.
Relevant code
https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobOperator.java#L406-L413
For comparison, JobLauncherApplicationRunner handles this correctly:
https://github.com/spring-projects/spring-boot/blob/main/module/spring-boot-batch/src/main/java/org/springframework/boot/batch/autoconfigure/JobLauncherApplicationRunner.java#L148
Bug description
CommandLineJobOperator.parse()usesString.split("=")without a limit, which splits on every=character. This causes two problems:=get truncated (e.g. URLs with query strings)=throwArrayIndexOutOfBoundsExceptionThe deprecated
CommandLineJobRunnerand Spring Boot'sJobLauncherApplicationRunnerboth useStringUtils.splitArrayElementsIntoPropertieswhich correctly splits only on the first=.Environment
Spring Batch 6.0.x (all versions since
CommandLineJobOperatorwas introduced in 6.0)Steps to reproduce
Run a job via
CommandLineJobOperatorwith a parameter containing=in the value:Expected behavior
The parameter should be parsed as
url→http://example.com?id=123.Current behavior
split("=")produces["url", "http://example.com?id", "123"], so onlyhttp://example.com?idis stored as the value. The rest is lost.Relevant code
https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/CommandLineJobOperator.java#L406-L413
For comparison,
JobLauncherApplicationRunnerhandles this correctly:https://github.com/spring-projects/spring-boot/blob/main/module/spring-boot-batch/src/main/java/org/springframework/boot/batch/autoconfigure/JobLauncherApplicationRunner.java#L148