Uploaded image for project: 'Spring Batch'
  1. Spring Batch
  2. BATCH-2752

JsonFileItemWriter writes invalid json when write method called few times in a row.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.0.M3
    • Fix Version/s: 4.1.0, 4.1.0.RC1
    • Component/s: Infrastructure
    • Labels:
      None

      Description

      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"
      ]
      

        Attachments

          Activity

            People

            • Assignee:
              mbenhassine Mahmoud Ben Hassine
              Reporter:
              gd-estrepetov gd-estrepetov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: