Skip to content

Commit

Permalink
Merge pull request #31 from georchestra/fix-closing-stream
Browse files Browse the repository at this point in the history
fix: auto closing stream in try with res
  • Loading branch information
f-necas authored May 28, 2024
2 parents fabbcfb + bacb5c0 commit fd82c4c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.stream.Stream;

import com.camptocamp.opendata.model.GeodataRecord;
import com.camptocamp.opendata.model.GeometryProperty;
Expand Down Expand Up @@ -65,7 +66,9 @@ private void serializeContent(FeatureCollection collection, JsonGenerator genera

generator.writeFieldName("records");
generator.writeStartArray();
collection.getFeatures().forEach(rec -> write(rec, generator));
try (Stream<GeodataRecord> stream = collection.getFeatures()){
stream.forEach(rec -> write(rec, generator));
}
generator.writeEndArray();

generator.writeFieldName("links");
Expand Down

0 comments on commit fd82c4c

Please sign in to comment.