Closed
Description
Bug description
DefaultJobParamatersConverter
class's private parseValue(String encodedJobParameter)
method throws java.lang.ArrayIndexOutOfBoundsException
if the parameter encodedJobParameter
is null or empty.
This causes the batch app started from the command line to not accept empty command line arguments in the format arg1=
.
Environment
Java 17
Spring Boot 3.1.4
Spring Batch 5.0.3
Expected behavior
Job parameter should be null or empty.
Minimal Complete Reproducible example
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class Test {
@Autowired
DefaultJobParametersConverter converter;
@Test
void testConversion() {
Properties props = new Properties();
props.put("arg1", "");
assertEquals("", converter.getJobParameters(props).getString("arg1"));
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
hwan33 commentedon Dec 11, 2023
It seems that it is impossible to distinguish whether its value is null or empty string.
StringUtils.commaDelimitedListToStringArray(encodedJobParameter)
returnsEMPTY_STRING_ARRAY
for both values.fmbenhassine commentedon Feb 14, 2024
Thank you for raising this issue! The framework should not fail with an
java.lang.ArrayIndexOutOfBoundsException
if the value is empty. Job parameters are not designed to acceptnull
values, so in that case the value should be an empty String.Fix exception when parsing empty values in DefaultJobParametersConverter
Fix exception when parsing empty values in DefaultJobParametersConverter
Fix exception when parsing empty values in DefaultJobParametersConverter
4 remaining items