Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
FlatFileItemReaderBuilder class - TAB character is not set as a delimiter [BATCH-2738] #866
Hi Spring Batch Team,
My name is Valentin, I am from Romania, I am Java Application Developer and I work for a project by using Spring Batch Core framework.
I use your new feature Spring Batch Core 4 class org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder.DelimitedBuilder. In my code, I want to set the TAB delimiter by the next sequence:
FlatFileItemReaderBuilder<MyData> flatFileItemReaderBuilder = new FlatFileItemReaderBuilder<>();
I've found +the TAB character is not set as a delimiter+ on the field org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder.DelimitedBuilder.delimiter. I've found that, in general, the delimiter is set by the method org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder.DelimitedBuilder.build() at line 631, by the sequence:
Here the delimiter is checked against the method org.springframework.util.StringUtils.hasText(String). According to the hasText() method specification, "this method returns true if the String is not null, its length is greater than 0, and it contains at least one non-whitespace character." But in the case of TAB character, the string contains only one character (i.e. TAB character) which is a whitespace character, thus the condition is not valid, and the TAB character is not set as a delimiter.
Please correct me if I am wrong. As long as DelimitedLineTokenizer.DELIMITER_TAB constant exists, to exclude the TAB character was not an intention, and maybe this is a bug.
P.S. For the moment, I have solved the problem by using the classic Spring Batch 3 style.