Skip to content

Commit

Permalink
fix (core): Fix subtle bug in WritableResourceRDFHandler which appear…
Browse files Browse the repository at this point in the history
…ed during RDF4j 5.0.1 to 5.0.2 upgrade

Related to eclipse-rdf4j/rdf4j#5096.
  • Loading branch information
vorburger committed Oct 2, 2024
1 parent a42371e commit 6c6cdc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions java/dev/enola/core/rosetta/RosettaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import dev.enola.common.io.resource.MemoryResource;
import dev.enola.common.io.resource.ResourceProvider;
import dev.enola.common.io.resource.StringResource;
import dev.enola.common.yamljson.JSON;
import dev.enola.rdf.io.RdfLoader;
import dev.enola.rdf.io.RdfMediaTypes;
import dev.enola.thing.Thing;
Expand Down Expand Up @@ -134,6 +135,16 @@ public void testJsonToTurtle() throws Exception {
assertThat(out.charSource().read()).contains("firstName> \"Salvador\"");
}

@Test
public void testJsonToJsonld() throws Exception {
var in = rp.get("classpath:/picasso.json?context=classpath:/picasso-context.jsonld");
var out = new MemoryResource(RdfMediaTypes.JSON_LD);
rosetta.convertInto(in, out);
// This is to detect invalid JSON, which happened during the RDF4j 5.0.1 to 5.0.2 upgrade
JSON.readObject(out.charSource().read());
assertThat(out.charSource().read()).contains("firstName");
}

@Test
public void testYamlToTurtle() throws Exception {
var in = rp.get("classpath:/picasso.yaml?context=classpath:/picasso-context.jsonld");
Expand Down
4 changes: 2 additions & 2 deletions java/dev/enola/rdf/io/WritableResourceRDFHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private WritableResourceRDFHandler(RDFWriter rdfWriter, Writer ioWriter)

@Override
public void close() throws IOException {
endRDF();
rdfWriter.endRDF();
ioWriter.close();
}

Expand All @@ -78,7 +78,7 @@ public void startRDF() throws RDFHandlerException {

@Override
public void endRDF() throws RDFHandlerException {
rdfWriter.endRDF();
// SUPPRESS rdfWriter.endRDF();
}

@Override
Expand Down

0 comments on commit 6c6cdc6

Please sign in to comment.