Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonFileItemWriter writes invalid json when write method called few times in a row. [BATCH-2752] #852

Closed
spring-issuemaster opened this issue Sep 5, 2018 · 0 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 5, 2018

gd-estrepetov opened BATCH-2752 and commented

JsonFileItemWriter adds unnecessary "," when data is written in chunks to json file.

Code to reproduce:

List<String> firstList = Arrays.asList("one", "two");
List<String> secondList = Arrays.asList("three", "four");

JsonFileItemWriter<String> writer = new JsonFileItemWriterBuilder<String>()
        .name("writer")
        .resource(new FileSystemResource("test.json"))
        .jsonObjectMarshaller(new JacksonJsonObjectMarshaller<>())
        .build();

writer.open(new ExecutionContext());
writer.write(firstList);
writer.write(secondList);

writer.close();

Result:

[
 "one",
 "two",
 "three",
,
 "four"
]

Affects: 4.1.0.M3

Referenced from: pull request #636

Backported to: 4.1.0.RC1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.