diff --git a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/RDF4JProtocolSession.java b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/RDF4JProtocolSession.java
index 0a9bf6e7149..bb35d09e809 100644
--- a/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/RDF4JProtocolSession.java
+++ b/core/http/client/src/main/java/org/eclipse/rdf4j/http/client/RDF4JProtocolSession.java
@@ -84,7 +84,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.databind.ObjectMapper;
/**
* A {@link SPARQLProtocolSession} subclass which extends the standard SPARQL 1.1 Protocol with additional
diff --git a/core/query/pom.xml b/core/query/pom.xml
index 6132cf3c2a8..774bee99c96 100644
--- a/core/query/pom.xml
+++ b/core/query/pom.xml
@@ -25,12 +25,14 @@
jackson-annotations
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-core
+ ${jackson3.version}
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-databind
+ ${jackson3.version}
org.apache.commons
diff --git a/core/query/src/main/java/org/eclipse/rdf4j/query/explanation/ExplanationImpl.java b/core/query/src/main/java/org/eclipse/rdf4j/query/explanation/ExplanationImpl.java
index b80e9b2a557..c1a321610a5 100644
--- a/core/query/src/main/java/org/eclipse/rdf4j/query/explanation/ExplanationImpl.java
+++ b/core/query/src/main/java/org/eclipse/rdf4j/query/explanation/ExplanationImpl.java
@@ -15,8 +15,9 @@
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.json.JsonMapper;
/**
* This is an experimental feature. It may be changed, moved or potentially removed in a future release.
@@ -37,7 +38,12 @@ public ExplanationImpl(GenericPlanNode genericPlanNode, boolean timedOut, Object
}
}
- ObjectMapper objectMapper = new ObjectMapper();
+ ObjectMapper objectMapper = JsonMapper.builder()
+ .changeDefaultVisibility(vc -> vc
+ .withVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.PUBLIC_ONLY)
+ .withVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE))
+ .changeDefaultPropertyInclusion(incl -> incl.withValueInclusion(JsonInclude.Include.NON_NULL))
+ .build();
@Override
public Object tupleExpr() {
@@ -51,16 +57,10 @@ public GenericPlanNode toGenericPlanNode() {
@Override
public String toJson() {
- try {
- // TODO: Consider removing pretty printer
- return this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.PUBLIC_ONLY)
- .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.NONE)
- .setSerializationInclusion(JsonInclude.Include.NON_NULL)
- .writerWithDefaultPrettyPrinter()
- .writeValueAsString(toGenericPlanNode());
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
+ // TODO: Consider removing pretty printer
+ return this.objectMapper
+ .writerWithDefaultPrettyPrinter()
+ .writeValueAsString(toGenericPlanNode());
}
@Override
diff --git a/core/queryresultio/sparqljson/pom.xml b/core/queryresultio/sparqljson/pom.xml
index 6b8e53261d0..16d4e05ca07 100644
--- a/core/queryresultio/sparqljson/pom.xml
+++ b/core/queryresultio/sparqljson/pom.xml
@@ -26,8 +26,9 @@
${project.version}
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-core
+ ${jackson3.version}
${project.groupId}
diff --git a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONParser.java b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONParser.java
index 3dfff227403..9f924be36a9 100644
--- a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONParser.java
+++ b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONParser.java
@@ -41,14 +41,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonFactoryBuilder;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.core.StreamReadFeature;
-import com.fasterxml.jackson.core.StreamWriteFeature;
-import com.fasterxml.jackson.core.json.JsonReadFeature;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.StreamReadFeature;
+import tools.jackson.core.StreamWriteFeature;
+import tools.jackson.core.TokenStreamFactory;
+import tools.jackson.core.json.JsonFactory;
+import tools.jackson.core.json.JsonReadFeature;
/**
* Abstract base class for SPARQL Results JSON Parsers. Provides a common implementation of both boolean and tuple
@@ -134,7 +134,7 @@ protected boolean parseQueryResultInternal(InputStream in, boolean attemptParseB
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new QueryResultParseException("Expected SPARQL Results JSON document to start with an Object",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
List varsList = new ArrayList<>();
@@ -143,27 +143,27 @@ protected boolean parseQueryResultInternal(InputStream in, boolean attemptParseB
while (jp.nextToken() != JsonToken.END_OBJECT) {
- final String baseStr = jp.getCurrentName();
+ final String baseStr = jp.currentName();
if (baseStr.equals(HEAD)) {
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new QueryResultParseException("Did not find object under " + baseStr + " field",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- final String headStr = jp.getCurrentName();
+ final String headStr = jp.currentName();
if (headStr.equals(VARS)) {
if (!attemptParseTuple) {
throw new QueryResultParseException(
"Found tuple results variables when attempting to parse SPARQL Results JSON to boolean result",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getLineNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
if (jp.nextToken() != JsonToken.START_ARRAY) {
throw new QueryResultParseException("Expected variable labels to be an array",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_ARRAY) {
@@ -190,7 +190,7 @@ protected boolean parseQueryResultInternal(InputStream in, boolean attemptParseB
List linksList = new ArrayList<>();
if (jp.nextToken() != JsonToken.START_ARRAY) {
throw new QueryResultParseException("Expected links to be an array",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_ARRAY) {
@@ -203,48 +203,48 @@ protected boolean parseQueryResultInternal(InputStream in, boolean attemptParseB
} else {
throw new QueryResultParseException("Found unexpected object in head field: " + headStr,
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
}
} else if (baseStr.equals(RESULTS)) {
if (!attemptParseTuple) {
throw new QueryResultParseException(
"Found tuple results bindings when attempting to parse SPARQL Results JSON to boolean result",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getLineNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new QueryResultParseException(
- "Found unexpected token in results object: " + jp.getCurrentName(),
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ "Found unexpected token in results object: " + jp.currentName(),
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentName().equals(BINDINGS)) {
+ if (jp.currentName().equals(BINDINGS)) {
if (jp.nextToken() != JsonToken.START_ARRAY) {
throw new QueryResultParseException("Found unexpected token in bindings object",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_ARRAY) {
MapBindingSet nextBindingSet = new MapBindingSet();
- if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
+ if (jp.currentToken() != JsonToken.START_OBJECT) {
throw new QueryResultParseException(
- "Did not find object in bindings array: " + jp.getCurrentName(),
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ "Did not find object in bindings array: " + jp.currentName(),
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
+ if (jp.currentToken() != JsonToken.PROPERTY_NAME) {
throw new QueryResultParseException("Did not find binding name",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
- final String bindingStr = jp.getCurrentName();
+ final String bindingStr = jp.currentName();
nextBindingSet.addBinding(bindingStr, parseValue(jp, bindingStr));
}
@@ -266,19 +266,19 @@ protected boolean parseQueryResultInternal(InputStream in, boolean attemptParseB
}
// Backwards compatibility with very old draft of the original
// SPARQL spec
- else if (jp.getCurrentName().equals(DISTINCT) || jp.getCurrentName().equals(ORDERED)) {
+ else if (jp.currentName().equals(DISTINCT) || jp.currentName().equals(ORDERED)) {
jp.nextToken();
} else {
throw new QueryResultParseException(
- "Found unexpected field in results: " + jp.getCurrentName(),
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ "Found unexpected field in results: " + jp.currentName(),
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
}
} else if (baseStr.equals(BOOLEAN)) {
if (!attemptParseBoolean) {
throw new QueryResultParseException(
"Found boolean results when attempting to parse SPARQL Results JSON to tuple results",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getLineNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
jp.nextToken();
@@ -288,35 +288,35 @@ else if (jp.getCurrentName().equals(DISTINCT) || jp.getCurrentName().equals(ORDE
}
} else {
logger.debug("Found unexpected object in top level {} field #{}.{}", baseStr,
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
// Consume the discovered unexpected object
// (in particular, if it is either an array or a composite object).
jp.nextToken();
if (jp.currentToken() == JsonToken.START_ARRAY) {
- while (!(jp.getParsingContext().getParent().inRoot()
+ while (!(jp.streamReadContext().getParent().inRoot()
&& (jp.currentToken() == JsonToken.END_ARRAY))) {
if (jp.nextToken() == null) {
throw new QueryResultParseException(
"An array value of the unexpected " + baseStr + " field is not closed.",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getLineNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
}
} else if (jp.currentToken() == JsonToken.START_OBJECT) {
- while (!(jp.getParsingContext().getParent().inRoot()
+ while (!(jp.streamReadContext().getParent().inRoot()
&& (jp.currentToken() == JsonToken.END_OBJECT))) {
if (jp.nextToken() == null) {
throw new QueryResultParseException(
"An object value of the unexpected " + baseStr + " field is not closed.",
- jp.getCurrentLocation().getLineNr(), jp.getCurrentLocation().getLineNr());
+ jp.currentLocation().getLineNr(), jp.currentLocation().getColumnNr());
}
}
}
}
}
- } catch (JsonProcessingException e) {
+ } catch (JacksonException e) {
throw new QueryResultParseException("Could not parse SPARQL/JSON", e, e.getLocation().getLineNr(),
- e.getLocation().getLineNr());
+ e.getLocation().getColumnNr());
}
return result;
@@ -325,8 +325,8 @@ else if (jp.getCurrentName().equals(DISTINCT) || jp.getCurrentName().equals(ORDE
protected Value parseValue(JsonParser jp, String bindingStr) throws IOException {
if (jp.nextToken() != JsonToken.START_OBJECT) {
throw new QueryResultParseException("Did not find object for binding value",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
String lang = null;
@@ -337,17 +337,17 @@ protected Value parseValue(JsonParser jp, String bindingStr) throws IOException
Triple triple = null;
while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
+ if (jp.currentToken() != JsonToken.PROPERTY_NAME) {
throw new QueryResultParseException(
"Did not find value attribute under " + bindingStr + " field",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
- String fieldName = jp.getCurrentName();
+ String fieldName = jp.currentName();
// set the appropriate state variable
if (TYPE.equals(fieldName)) {
- type = jp.nextTextValue();
+ type = jp.nextStringValue();
if (TRIPLE_STARDOG.equals(type)) {
// Stardog RDF-star serialization dialect does not wrap the triple in a value object
triple = parseStardogTripleValue(jp, type);
@@ -355,24 +355,24 @@ protected Value parseValue(JsonParser jp, String bindingStr) throws IOException
break;
}
} else if (XMLLANG.equals(fieldName)) {
- lang = jp.nextTextValue();
+ lang = jp.nextStringValue();
} else if (DATATYPE.equals(fieldName)) {
- datatype = jp.nextTextValue();
+ datatype = jp.nextStringValue();
} else if (VALUE.equals(fieldName)) {
if (jp.nextToken() == JsonToken.START_OBJECT) {
triple = parseTripleValue(jp, fieldName);
- if (jp.getCurrentToken() != JsonToken.END_OBJECT) {
- throw new QueryResultParseException("Unexpected token: " + jp.getCurrentName(),
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ if (jp.currentToken() != JsonToken.END_OBJECT) {
+ throw new QueryResultParseException("Unexpected token: " + jp.currentName(),
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
} else {
value = jp.getText();
}
} else {
throw new QueryResultParseException("Unexpected field name: " + fieldName,
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
}
@@ -387,34 +387,34 @@ private Triple parseStardogTripleValue(JsonParser jp, String fieldName) throws I
Value subject = null, predicate = null, object = null;
while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
+ if (jp.currentToken() != JsonToken.PROPERTY_NAME) {
throw new QueryResultParseException("Did not find triple attribute in triple value",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
- String posName = jp.getCurrentName();
+ String posName = jp.currentName();
if (SUBJECT.equals(posName)) {
if (subject != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
subject = parseValue(jp, fieldName + ":" + posName);
} else if (PREDICATE.equals(posName)) {
if (predicate != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
predicate = parseValue(jp, fieldName + ":" + posName);
} else if (OBJECT.equals(posName)) {
if (object != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
object = parseValue(jp, fieldName + ":" + posName);
} else if ("g".equals(posName)) {
@@ -422,8 +422,8 @@ private Triple parseStardogTripleValue(JsonParser jp, String fieldName) throws I
parseValue(jp, fieldName + ":" + posName);
} else {
throw new QueryResultParseException("Unexpected field name in triple value: " + posName,
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
}
@@ -431,14 +431,14 @@ private Triple parseStardogTripleValue(JsonParser jp, String fieldName) throws I
return valueFactory.createTriple((Resource) subject, (IRI) predicate, object);
} else {
throw new QueryResultParseException("Incomplete or invalid triple value",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
}
protected Triple parseTripleValue(JsonParser jp, String fieldName) throws IOException {
- throw new QueryResultParseException("Unexpected object as value", jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ throw new QueryResultParseException("Unexpected object as value", jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
protected boolean checkTripleType(JsonParser jp, String type) {
@@ -519,13 +519,13 @@ public Collection> getSupportedSettings() {
* @return A newly configured JsonFactory based on the currently enabled settings
*/
private JsonFactory configureNewJsonFactory() {
- final JsonFactoryBuilder builder = new JsonFactoryBuilder();
+ var builder = JsonFactory.builder();
// Disable features that may work for most JSON where the field names are
// in limited supply,
// but does not work for SPARQL/JSON where a wide range of URIs are used for
// subjects and predicates
- builder.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
- builder.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES);
+ builder.disable(TokenStreamFactory.Feature.INTERN_PROPERTY_NAMES);
+ builder.disable(TokenStreamFactory.Feature.CANONICALIZE_PROPERTY_NAMES);
builder.disable(StreamWriteFeature.AUTO_CLOSE_TARGET);
if (getParserConfig().isSet(JSONSettings.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)) {
@@ -553,7 +553,7 @@ private JsonFactory configureNewJsonFactory() {
getParserConfig().get(JSONSettings.ALLOW_UNQUOTED_CONTROL_CHARS));
}
if (getParserConfig().isSet(JSONSettings.ALLOW_UNQUOTED_FIELD_NAMES)) {
- builder.configure(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES,
+ builder.configure(JsonReadFeature.ALLOW_UNQUOTED_PROPERTY_NAMES,
getParserConfig().get(JSONSettings.ALLOW_UNQUOTED_FIELD_NAMES));
}
if (getParserConfig().isSet(JSONSettings.ALLOW_YAML_COMMENTS)) {
diff --git a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONWriter.java b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONWriter.java
index 2c819912c90..b8b36f9a75e 100644
--- a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONWriter.java
+++ b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/AbstractSPARQLJSONWriter.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.rdf4j.query.resultio.sparqljson;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
@@ -37,13 +36,16 @@
import org.eclipse.rdf4j.rio.RioSetting;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonFactoryBuilder;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.StreamWriteFeature;
-import com.fasterxml.jackson.core.util.DefaultIndenter;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Indenter;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.PrettyPrinter;
+import tools.jackson.core.StreamWriteFeature;
+import tools.jackson.core.TokenStreamFactory;
+import tools.jackson.core.json.JsonFactory;
+import tools.jackson.core.util.DefaultIndenter;
+import tools.jackson.core.util.DefaultPrettyPrinter;
+import tools.jackson.core.util.DefaultPrettyPrinter.Indenter;
/**
* An abstract class to implement the base functionality for both SPARQLBooleanJSONWriter and SPARQLResultsJSONWriter.
@@ -52,14 +54,14 @@
*/
abstract class AbstractSPARQLJSONWriter extends AbstractQueryResultWriter implements CharSink {
- private static final JsonFactory JSON_FACTORY = new JsonFactoryBuilder()
+ private static final JsonFactory JSON_FACTORY = JsonFactory.builder()
// Disable features that may work for most JSON where the field names are
// in limited supply,
// but does not work for RDF/JSON where a wide range of URIs are used for
// subjects and
// predicates
- .disable(JsonFactory.Feature.INTERN_FIELD_NAMES)
- .disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES)
+ .disable(TokenStreamFactory.Feature.INTERN_PROPERTY_NAMES)
+ .disable(TokenStreamFactory.Feature.CANONICALIZE_PROPERTY_NAMES)
.disable(StreamWriteFeature.AUTO_CLOSE_TARGET)
.build();
@@ -75,7 +77,7 @@ abstract class AbstractSPARQLJSONWriter extends AbstractQueryResultWriter implem
protected boolean linksFound = false;
- protected final JsonGenerator jg;
+ protected JsonGenerator jg;
private final Writer writer;
@@ -85,11 +87,6 @@ protected AbstractSPARQLJSONWriter(OutputStream out) {
protected AbstractSPARQLJSONWriter(Writer writer) {
this.writer = writer;
- try {
- jg = JSON_FACTORY.createGenerator(writer);
- } catch (IOException e) {
- throw new IllegalArgumentException(e);
- }
}
@Override
@@ -105,13 +102,13 @@ public void endHeader() throws QueryResultHandlerException {
if (tupleVariablesFound) {
// Write results
- jg.writeObjectFieldStart("results");
+ jg.writeObjectPropertyStart("results");
- jg.writeArrayFieldStart("bindings");
+ jg.writeArrayPropertyStart("bindings");
}
headerComplete = true;
- } catch (IOException e) {
+ } catch (JacksonException e) {
throw new QueryResultHandlerException(e);
}
}
@@ -131,12 +128,12 @@ public void startQueryResult(List columnHeaders) throws TupleQueryResult
}
tupleVariablesFound = true;
- jg.writeArrayFieldStart("vars");
+ jg.writeArrayPropertyStart("vars");
for (String nextColumn : columnHeaders) {
jg.writeString(nextColumn);
}
jg.writeEndArray();
- } catch (IOException | QueryResultHandlerException e) {
+ } catch (JacksonException | QueryResultHandlerException e) {
throw new TupleQueryResultHandlerException(e);
}
}
@@ -167,12 +164,12 @@ protected void handleSolutionImpl(BindingSet bindingSet) throws TupleQueryResult
Iterator bindingIter = bindingSet.iterator();
while (bindingIter.hasNext()) {
Binding binding = bindingIter.next();
- jg.writeFieldName(binding.getName());
+ jg.writeName(binding.getName());
writeValue(binding.getValue());
}
jg.writeEndObject();
- } catch (IOException | QueryResultHandlerException e) {
+ } catch (JacksonException | QueryResultHandlerException e) {
throw new TupleQueryResultHandlerException(e);
}
}
@@ -201,7 +198,7 @@ public void endQueryResult() throws TupleQueryResultHandlerException {
// results braces
jg.writeEndObject();
endDocument();
- } catch (IOException | QueryResultHandlerException e) {
+ } catch (JacksonException | QueryResultHandlerException e) {
throw new TupleQueryResultHandlerException(e);
}
}
@@ -216,17 +213,23 @@ public void startDocument() throws QueryResultHandlerException {
firstTupleWritten = false;
linksFound = false;
+ // Create the generator here so the pretty printer setting (which requires the writer config)
+ // is known at generator construction time, as Jackson 3 reads it from the ObjectWriteContext eagerly.
+ final PrettyPrinter pp;
if (getWriterConfig().get(BasicWriterSettings.PRETTY_PRINT)) {
// SES-2011: Always use \n for consistency
Indenter indenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;
- // By default Jackson does not pretty print, so enable this unless
- // PRETTY_PRINT setting is disabled
- DefaultPrettyPrinter pp = new DefaultPrettyPrinter().withArrayIndenter(indenter)
- .withObjectIndenter(indenter);
- jg.setPrettyPrinter(pp);
+ pp = new DefaultPrettyPrinter().withArrayIndenter(indenter).withObjectIndenter(indenter);
+ } else {
+ pp = null;
}
-
try {
+ jg = JSON_FACTORY.createGenerator(new ObjectWriteContext.Base() {
+ @Override
+ public PrettyPrinter getPrettyPrinter() {
+ return pp;
+ }
+ }, writer);
if (getWriterConfig().isSet(BasicQueryWriterSettings.JSONP_CALLBACK)) {
// SES-1019 : Write the callbackfunction name as a wrapper for
// the results here
@@ -235,7 +238,7 @@ public void startDocument() throws QueryResultHandlerException {
jg.writeRaw("(");
}
jg.writeStartObject();
- } catch (IOException e) {
+ } catch (JacksonException e) {
throw new QueryResultHandlerException(e);
}
}
@@ -255,10 +258,10 @@ public void startHeader() throws QueryResultHandlerException {
if (!headerOpen) {
try {
// Write header
- jg.writeObjectFieldStart("head");
+ jg.writeObjectPropertyStart("head");
headerOpen = true;
- } catch (IOException e) {
+ } catch (JacksonException e) {
throw new QueryResultHandlerException(e);
}
}
@@ -275,41 +278,41 @@ public void handleLinks(List linkUrls) throws QueryResultHandlerExceptio
startHeader();
}
- jg.writeArrayFieldStart("link");
+ jg.writeArrayPropertyStart("link");
for (String nextLink : linkUrls) {
jg.writeString(nextLink);
}
jg.writeEndArray();
- } catch (IOException e) {
+ } catch (JacksonException e) {
throw new QueryResultHandlerException(e);
}
}
- protected void writeValue(Value value) throws IOException, QueryResultHandlerException {
+ protected void writeValue(Value value) throws QueryResultHandlerException {
jg.writeStartObject();
if (value instanceof IRI) {
- jg.writeStringField("type", "uri");
- jg.writeStringField("value", ((IRI) value).toString());
+ jg.writeStringProperty("type", "uri");
+ jg.writeStringProperty("value", ((IRI) value).toString());
} else if (value instanceof BNode) {
- jg.writeStringField("type", "bnode");
- jg.writeStringField("value", ((BNode) value).getID());
+ jg.writeStringProperty("type", "bnode");
+ jg.writeStringProperty("value", ((BNode) value).getID());
} else if (value instanceof Literal) {
Literal lit = (Literal) value;
if (Literals.isLanguageLiteral(lit)) {
- jg.writeObjectField("xml:lang", lit.getLanguage().orElse(null));
+ jg.writeStringProperty("xml:lang", lit.getLanguage().orElse(null));
} else {
IRI datatype = lit.getDatatype();
boolean ignoreDatatype = datatype.equals(XSD.STRING) && xsdStringToPlainLiteral();
if (!ignoreDatatype) {
- jg.writeObjectField("datatype", lit.getDatatype().stringValue());
+ jg.writeStringProperty("datatype", lit.getDatatype().stringValue());
}
}
- jg.writeObjectField("type", "literal");
+ jg.writeStringProperty("type", "literal");
- jg.writeObjectField("value", lit.getLabel());
+ jg.writeStringProperty("value", lit.getLabel());
} else {
throw new TupleQueryResultHandlerException("Unknown Value object type: " + value.getClass());
}
@@ -336,13 +339,13 @@ public void handleBoolean(boolean value) throws QueryResultHandlerException {
try {
if (value) {
- jg.writeBooleanField("boolean", Boolean.TRUE);
+ jg.writeBooleanProperty("boolean", Boolean.TRUE);
} else {
- jg.writeBooleanField("boolean", Boolean.FALSE);
+ jg.writeBooleanProperty("boolean", Boolean.FALSE);
}
endDocument();
- } catch (IOException e) {
+ } catch (JacksonException e) {
throw new QueryResultHandlerException(e);
}
}
@@ -361,7 +364,7 @@ public void handleNamespace(String prefix, String uri) throws QueryResultHandler
// Ignored by SPARQLJSONWriterBase
}
- protected void endDocument() throws IOException {
+ protected void endDocument() throws JacksonException {
jg.writeEndObject();
if (getWriterConfig().isSet(BasicQueryWriterSettings.JSONP_CALLBACK)) {
jg.writeRaw(");");
diff --git a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONParser.java b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONParser.java
index 9d8ea6f98e0..88f2bce7ace 100644
--- a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONParser.java
+++ b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONParser.java
@@ -35,8 +35,8 @@
import org.eclipse.rdf4j.query.resultio.TupleQueryResultFormat;
import org.eclipse.rdf4j.query.resultio.TupleQueryResultParser;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
/**
* Parser for SPARQL-1.1 JSON Results Format documents.
@@ -95,34 +95,34 @@ protected Triple parseTripleValue(JsonParser jp, String fieldName) throws IOExce
Value subject = null, predicate = null, object = null;
while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
+ if (jp.currentToken() != JsonToken.PROPERTY_NAME) {
throw new QueryResultParseException("Did not find triple attribute in triple value",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
- String posName = jp.getCurrentName();
+ String posName = jp.currentName();
if (SUBJECT.equals(posName) || SUBJECT_JENA.equals(posName)) {
if (subject != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
subject = parseValue(jp, fieldName + ":" + posName);
} else if (PREDICATE.equals(posName) || PREDICATE_JENA.equals(posName)) {
if (predicate != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
predicate = parseValue(jp, fieldName + ":" + posName);
} else if (OBJECT.equals(posName) || OBJECT_JENA.equals(posName)) {
if (object != null) {
throw new QueryResultParseException(
posName + " field encountered twice in triple value: ",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
object = parseValue(jp, fieldName + ":" + posName);
} else if ("g".equals(posName)) {
@@ -130,8 +130,8 @@ protected Triple parseTripleValue(JsonParser jp, String fieldName) throws IOExce
parseValue(jp, fieldName + ":" + posName);
} else {
throw new QueryResultParseException("Unexpected field name in triple value: " + posName,
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
}
@@ -139,8 +139,8 @@ protected Triple parseTripleValue(JsonParser jp, String fieldName) throws IOExce
return valueFactory.createTriple((Resource) subject, (IRI) predicate, object);
} else {
throw new QueryResultParseException("Incomplete or invalid triple value",
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
}
@@ -148,8 +148,8 @@ protected Triple parseTripleValue(JsonParser jp, String fieldName) throws IOExce
protected boolean checkTripleType(JsonParser jp, String type) {
if (!TRIPLE.equals(type) && !TRIPLE_STARDOG.equals(type)) {
throw new QueryResultParseException("Found a triple value but unexpected type: " + type,
- jp.getCurrentLocation().getLineNr(),
- jp.getCurrentLocation().getColumnNr());
+ jp.currentLocation().getLineNr(),
+ jp.currentLocation().getColumnNr());
}
return true;
diff --git a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONWriter.java b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONWriter.java
index e3b6f356630..5a97491d209 100644
--- a/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONWriter.java
+++ b/core/queryresultio/sparqljson/src/main/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLResultsJSONWriter.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.rdf4j.query.resultio.sparqljson;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
@@ -53,21 +52,21 @@ public TupleQueryResultFormat getQueryResultFormat() {
}
@Override
- protected void writeValue(Value value) throws IOException, QueryResultHandlerException {
+ protected void writeValue(Value value) throws QueryResultHandlerException {
if (value instanceof Triple) {
jg.writeStartObject();
- jg.writeStringField(AbstractSPARQLJSONParser.TYPE, SPARQLStarResultsJSONConstants.TRIPLE);
+ jg.writeStringProperty(AbstractSPARQLJSONParser.TYPE, SPARQLStarResultsJSONConstants.TRIPLE);
- jg.writeObjectFieldStart(AbstractSPARQLJSONParser.VALUE);
+ jg.writeObjectPropertyStart(AbstractSPARQLJSONParser.VALUE);
- jg.writeFieldName(SPARQLStarResultsJSONConstants.SUBJECT);
+ jg.writeName(SPARQLStarResultsJSONConstants.SUBJECT);
writeValue(((Triple) value).getSubject());
- jg.writeFieldName(SPARQLStarResultsJSONConstants.PREDICATE);
+ jg.writeName(SPARQLStarResultsJSONConstants.PREDICATE);
writeValue(((Triple) value).getPredicate());
- jg.writeFieldName(SPARQLStarResultsJSONConstants.OBJECT);
+ jg.writeName(SPARQLStarResultsJSONConstants.OBJECT);
writeValue(((Triple) value).getObject());
jg.writeEndObject();
diff --git a/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONParserCustomTest.java b/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONParserCustomTest.java
index 963d7eaa8ac..a4e986036b8 100644
--- a/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONParserCustomTest.java
+++ b/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONParserCustomTest.java
@@ -40,8 +40,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.io.ContentReference;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.io.ContentReference;
/**
* Custom (non-manifest) tests for SPARQL/JSON parser.
@@ -356,8 +356,8 @@ public void testIncludeSourceLocationDefault() throws Exception {
fail("Expected to find an exception");
} catch (QueryResultParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
ContentReference reference = cause.getLocation().contentReference();
assertTrue(ContentReference.unknown().equals(reference) || source.equals(reference.getRawContent()));
@@ -373,8 +373,8 @@ public void testIncludeSourceLocationEnabled() throws Exception {
fail("Expected to find an exception");
} catch (QueryResultParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
assertNotEquals(ContentReference.unknown(), cause.getLocation().contentReference());
assertEquals(source, cause.getLocation().contentReference().getRawContent());
@@ -389,8 +389,8 @@ public void testIncludeSourceLocationDisabled() throws Exception {
fail("Expected to find an exception");
} catch (QueryResultParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
assertEquals(ContentReference.unknown(), cause.getLocation().contentReference());
}
diff --git a/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONPrettyPrintTest.java b/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONPrettyPrintTest.java
new file mode 100644
index 00000000000..6d1c59e3a3a
--- /dev/null
+++ b/core/queryresultio/sparqljson/src/test/java/org/eclipse/rdf4j/query/resultio/sparqljson/SPARQLJSONPrettyPrintTest.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2025 Eclipse RDF4J contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Distribution License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *******************************************************************************/
+package org.eclipse.rdf4j.query.resultio.sparqljson;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.eclipse.rdf4j.model.vocabulary.RDF;
+import org.eclipse.rdf4j.query.impl.MapBindingSet;
+import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests that {@link BasicWriterSettings#PRETTY_PRINT} is honoured by the SPARQL JSON writers.
+ */
+public class SPARQLJSONPrettyPrintTest {
+
+ private static final SimpleValueFactory VF = SimpleValueFactory.getInstance();
+
+ // --- tuple writer helpers ------------------------------------------------
+
+ private String writeTupleResult(boolean prettyPrint) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ SPARQLResultsJSONWriter writer = new SPARQLResultsJSONWriter(out);
+ writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, prettyPrint);
+
+ MapBindingSet bs = new MapBindingSet();
+ bs.addBinding("s", VF.createIRI("http://example.org/subject"));
+ bs.addBinding("p", RDF.TYPE);
+ bs.addBinding("o", VF.createIRI("http://example.org/object"));
+
+ writer.startQueryResult(List.of("s", "p", "o"));
+ writer.handleSolution(bs);
+ writer.endQueryResult();
+
+ return out.toString(StandardCharsets.UTF_8);
+ }
+
+ @Test
+ public void tupleResultPrettyPrintEnabled() throws Exception {
+ String output = writeTupleResult(true);
+ assertThat(output).contains("\n");
+ }
+
+ @Test
+ public void tupleResultPrettyPrintDisabled() throws Exception {
+ String output = writeTupleResult(false);
+ assertThat(output).doesNotContain("\n");
+ }
+
+ @Test
+ public void tupleResultPrettyPrintOutputIsParseable() throws Exception {
+ // Sanity-check: pretty-printed output must still parse back to the same bindings.
+ String prettyOutput = writeTupleResult(true);
+ String compactOutput = writeTupleResult(false);
+
+ assertThat(prettyOutput).isNotEqualTo(compactOutput);
+
+ // Both outputs represent the same logical content: one binding with three variables.
+ for (String output : List.of(prettyOutput, compactOutput)) {
+ SPARQLResultsJSONParser parser = new SPARQLResultsJSONParser();
+ org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector collector = new org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector();
+ parser.setQueryResultHandler(collector);
+ parser.parseQueryResult(
+ new java.io.ByteArrayInputStream(output.getBytes(StandardCharsets.UTF_8)));
+ assertThat(collector.getBindingSets()).hasSize(1);
+ assertThat(collector.getBindingNames()).containsExactlyInAnyOrder("s", "p", "o");
+ }
+ }
+
+ // --- boolean writer helpers ----------------------------------------------
+
+ private String writeBooleanResult(boolean prettyPrint) throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ SPARQLBooleanJSONWriter writer = new SPARQLBooleanJSONWriter(out);
+ writer.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, prettyPrint);
+ writer.handleBoolean(true);
+ return out.toString(StandardCharsets.UTF_8);
+ }
+
+ @Test
+ public void booleanResultPrettyPrintEnabled() throws Exception {
+ String output = writeBooleanResult(true);
+ assertThat(output).contains("\n");
+ }
+
+ @Test
+ public void booleanResultPrettyPrintDisabled() throws Exception {
+ String output = writeBooleanResult(false);
+ assertThat(output).doesNotContain("\n");
+ }
+
+ @Test
+ public void booleanResultPrettyPrintOutputIsParseable() throws Exception {
+ // Sanity-check: pretty-printed output must still parse to the same boolean value.
+ String prettyOutput = writeBooleanResult(true);
+ String compactOutput = writeBooleanResult(false);
+
+ assertThat(prettyOutput).isNotEqualTo(compactOutput);
+
+ for (String output : List.of(prettyOutput, compactOutput)) {
+ SPARQLBooleanJSONParser parser = new SPARQLBooleanJSONParser(VF);
+ org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector collector = new org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector();
+ parser.setQueryResultHandler(collector);
+ parser.parseQueryResult(
+ new java.io.ByteArrayInputStream(output.getBytes(StandardCharsets.UTF_8)));
+ assertThat(collector.getBoolean()).isTrue();
+ }
+ }
+}
diff --git a/core/rio/api/pom.xml b/core/rio/api/pom.xml
index 1667bcf6272..72c5468221f 100644
--- a/core/rio/api/pom.xml
+++ b/core/rio/api/pom.xml
@@ -85,12 +85,14 @@
jackson-annotations
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-core
+ ${jackson3.version}
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-databind
+ ${jackson3.version}
commons-io
diff --git a/core/rio/api/src/main/java/org/eclipse/rdf4j/rio/helpers/SetRioSetting.java b/core/rio/api/src/main/java/org/eclipse/rdf4j/rio/helpers/SetRioSetting.java
index 236db8ee782..2e273455aef 100644
--- a/core/rio/api/src/main/java/org/eclipse/rdf4j/rio/helpers/SetRioSetting.java
+++ b/core/rio/api/src/main/java/org/eclipse/rdf4j/rio/helpers/SetRioSetting.java
@@ -17,9 +17,9 @@
import org.eclipse.rdf4j.rio.RioSetting;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.type.TypeReference;
+import tools.jackson.databind.ObjectMapper;
/**
* A {@link RioSetting} with a {@link Set} value. The given default for the setting can be overridden by means of a
@@ -41,7 +41,7 @@ public Set convert(String stringRepresentation) {
try {
return new HashSet<>(objectMapper.readValue(stringRepresentation, new TypeReference>() {
}));
- } catch (JsonProcessingException e) {
+ } catch (JacksonException e) {
throw new RuntimeException(e);
}
}
diff --git a/core/rio/rdfjson/pom.xml b/core/rio/rdfjson/pom.xml
index bbdc9d2b8f6..5a37f8a87b0 100644
--- a/core/rio/rdfjson/pom.xml
+++ b/core/rio/rdfjson/pom.xml
@@ -33,8 +33,9 @@
runtime
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-core
+ ${jackson3.version}
commons-io
diff --git a/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParser.java b/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParser.java
index a0f362b0a84..999a8112e4e 100644
--- a/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParser.java
+++ b/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParser.java
@@ -32,15 +32,16 @@
import org.eclipse.rdf4j.rio.helpers.AbstractRDFParser;
import org.eclipse.rdf4j.rio.helpers.JSONSettings;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonFactoryBuilder;
-import com.fasterxml.jackson.core.JsonLocation;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.core.StreamReadFeature;
-import com.fasterxml.jackson.core.StreamWriteFeature;
-import com.fasterxml.jackson.core.json.JsonReadFeature;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.StreamReadFeature;
+import tools.jackson.core.StreamWriteFeature;
+import tools.jackson.core.TokenStreamFactory;
+import tools.jackson.core.TokenStreamLocation;
+import tools.jackson.core.json.JsonFactory;
+import tools.jackson.core.json.JsonReadFeature;
/**
* {@link RDFParser} implementation for the RDF/JSON format
@@ -84,11 +85,11 @@ public void parse(final InputStream inputStream, final String baseUri)
this.rdfHandler.startRDF();
}
- jp = configureNewJsonFactory().createParser(inputStream);
+ jp = configureNewJsonFactory().createParser(ObjectReadContext.empty(), inputStream);
rdfJsonToHandlerInternal(this.rdfHandler, this.valueFactory, jp);
- } catch (final IOException e) {
+ } catch (JacksonException e) {
if (jp != null) {
- reportFatalError("Found IOException during parsing", e, jp.getCurrentLocation());
+ reportFatalError("Found exception during parsing", e, jp.currentLocation());
} else {
reportFatalError(e);
}
@@ -97,8 +98,8 @@ public void parse(final InputStream inputStream, final String baseUri)
if (jp != null) {
try {
jp.close();
- } catch (final IOException e) {
- reportFatalError("Found exception while closing JSON parser", e, jp.getCurrentLocation());
+ } catch (final JacksonException e) {
+ reportFatalError("Found exception while closing JSON parser", e, jp.currentLocation());
}
}
}
@@ -109,36 +110,36 @@ public void parse(final InputStream inputStream, final String baseUri)
/**
* Creates a literal, using the current value, language, and datatype, and additionally using the given
- * {@link JsonLocation} to provide information about the line and column numbers in the event of a warning, error or
- * exception being generated by the creation of the literal.
+ * {@link TokenStreamLocation} to provide information about the line and column numbers in the event of a warning,
+ * error or exception being generated by the creation of the literal.
*
* @param label the literal's lexical label
* @param language the literal's language tag. Can be null.
* @param datatype the literal's datatype. Can be null.
- * @param currentLocation the current JsonLocation. May not be null.
+ * @param currentLocation the current TokenStreamLocation. May not be null.
* @return the created {@link Literal} object.
* @throws RDFParseException
*/
- protected Literal createLiteral(String label, String language, IRI datatype, JsonLocation currentLocation)
+ protected Literal createLiteral(String label, String language, IRI datatype, TokenStreamLocation currentLocation)
throws RDFParseException {
return createLiteral(label, language, datatype, currentLocation.getLineNr(), currentLocation.getColumnNr());
}
- protected void reportError(String msg, Exception e, JsonLocation location, RioSetting setting)
+ protected void reportError(String msg, Exception e, TokenStreamLocation location, RioSetting setting)
throws RDFParseException {
reportError(msg, e, location.getLineNr(), location.getColumnNr(), setting);
}
- protected void reportError(String msg, JsonLocation location, RioSetting setting)
+ protected void reportError(String msg, TokenStreamLocation location, RioSetting setting)
throws RDFParseException {
reportError(msg, location.getLineNr(), location.getColumnNr(), setting);
}
- protected void reportFatalError(String msg, Exception e, JsonLocation location) throws RDFParseException {
+ protected void reportFatalError(String msg, Exception e, TokenStreamLocation location) throws RDFParseException {
reportFatalError(msg, e, location.getLineNr(), location.getColumnNr());
}
- protected void reportFatalError(String msg, JsonLocation location) throws RDFParseException {
+ protected void reportFatalError(String msg, TokenStreamLocation location) throws RDFParseException {
reportFatalError(msg, location.getLineNr(), location.getColumnNr());
}
@@ -154,11 +155,11 @@ public void parse(final Reader reader, final String baseUri)
this.rdfHandler.startRDF();
}
- jp = configureNewJsonFactory().createParser(reader);
+ jp = configureNewJsonFactory().createParser(ObjectReadContext.empty(), reader);
rdfJsonToHandlerInternal(rdfHandler, valueFactory, jp);
- } catch (final IOException e) {
+ } catch (JacksonException e) {
if (jp != null) {
- reportFatalError("Found IOException during parsing", e, jp.getCurrentLocation());
+ reportFatalError("Found exception during parsing", e, jp.currentLocation());
} else {
reportFatalError(e);
}
@@ -167,8 +168,8 @@ public void parse(final Reader reader, final String baseUri)
if (jp != null) {
try {
jp.close();
- } catch (final IOException e) {
- reportFatalError("Found exception while closing JSON parser", e, jp.getCurrentLocation());
+ } catch (final JacksonException e) {
+ reportFatalError("Found exception while closing JSON parser", e, jp.currentLocation());
}
}
}
@@ -178,37 +179,37 @@ public void parse(final Reader reader, final String baseUri)
}
private void rdfJsonToHandlerInternal(final RDFHandler handler, final ValueFactory vf, final JsonParser jp)
- throws IOException, JsonParseException, RDFParseException, RDFHandlerException {
+ throws RDFParseException, RDFHandlerException {
if (jp.nextToken() != JsonToken.START_OBJECT) {
- reportFatalError("Expected RDF/JSON document to start with an Object", jp.getCurrentLocation());
+ reportFatalError("Expected RDF/JSON document to start with an Object", jp.currentLocation());
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- final String subjStr = jp.getCurrentName();
+ final String subjStr = jp.currentName();
Resource subject;
subject = subjStr.startsWith("_:") ? createNode(subjStr.substring(2)) : vf.createIRI(subjStr);
if (jp.nextToken() != JsonToken.START_OBJECT) {
- reportFatalError("Expected subject value to start with an Object", jp.getCurrentLocation());
+ reportFatalError("Expected subject value to start with an Object", jp.currentLocation());
}
boolean foundPredicate = false;
while (jp.nextToken() != JsonToken.END_OBJECT) {
- final String predStr = jp.getCurrentName();
+ final String predStr = jp.currentName();
final IRI predicate = vf.createIRI(predStr);
foundPredicate = true;
if (jp.nextToken() != JsonToken.START_ARRAY) {
- reportFatalError("Expected predicate value to start with an array", jp.getCurrentLocation());
+ reportFatalError("Expected predicate value to start with an array", jp.currentLocation());
}
boolean foundObject = false;
while (jp.nextToken() != JsonToken.END_ARRAY) {
- if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
+ if (jp.currentToken() != JsonToken.START_OBJECT) {
reportFatalError("Expected object value to start with an Object: subject=<" + subjStr
- + "> predicate=<" + predStr + ">", jp.getCurrentLocation());
+ + "> predicate=<" + predStr + ">", jp.currentLocation());
}
String nextValue = null;
@@ -218,68 +219,68 @@ private void rdfJsonToHandlerInternal(final RDFHandler handler, final ValueFacto
final Set nextContexts = new HashSet<>(2);
while (jp.nextToken() != JsonToken.END_OBJECT) {
- final String fieldName = jp.getCurrentName();
+ final String fieldName = jp.currentName();
if (RDFJSONUtility.VALUE.equals(fieldName)) {
if (nextValue != null) {
reportError(
"Multiple values found for a single object: subject=" + subjStr + " predicate="
+ predStr,
- jp.getCurrentLocation(), RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_VALUES);
+ jp.currentLocation(), RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_VALUES);
}
jp.nextToken();
- nextValue = jp.getText();
+ nextValue = jp.getString();
} else if (RDFJSONUtility.TYPE.equals(fieldName)) {
if (nextType != null) {
reportError(
"Multiple types found for a single object: subject=" + subjStr + " predicate="
+ predStr,
- jp.getCurrentLocation(), RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_TYPES);
+ jp.currentLocation(), RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_TYPES);
}
jp.nextToken();
- nextType = jp.getText();
+ nextType = jp.getString();
} else if (RDFJSONUtility.LANG.equals(fieldName)) {
if (nextLanguage != null) {
reportError(
"Multiple languages found for a single object: subject=" + subjStr
+ " predicate=" + predStr,
- jp.getCurrentLocation(),
+ jp.currentLocation(),
RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_LANGUAGES);
}
jp.nextToken();
- nextLanguage = jp.getText();
+ nextLanguage = jp.getString();
} else if (RDFJSONUtility.DATATYPE.equals(fieldName)) {
if (nextDatatype != null) {
reportError(
"Multiple datatypes found for a single object: subject=" + subjStr
+ " predicate=" + predStr,
- jp.getCurrentLocation(),
+ jp.currentLocation(),
RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_DATATYPES);
}
jp.nextToken();
- nextDatatype = jp.getText();
+ nextDatatype = jp.getString();
} else if (RDFJSONUtility.GRAPHS.equals(fieldName)) {
if (jp.nextToken() != JsonToken.START_ARRAY) {
- reportError("Expected graphs to start with an array", jp.getCurrentLocation(),
+ reportError("Expected graphs to start with an array", jp.currentLocation(),
RDFJSONParserSettings.SUPPORT_GRAPHS_EXTENSION);
}
while (jp.nextToken() != JsonToken.END_ARRAY) {
- final String nextGraph = jp.getText();
+ final String nextGraph = jp.getString();
nextContexts.add(nextGraph);
}
} else {
reportError(
"Unrecognised JSON field name for object: subject=" + subjStr + " predicate="
+ predStr + " fieldname=" + fieldName,
- jp.getCurrentLocation(), RDFJSONParserSettings.FAIL_ON_UNKNOWN_PROPERTY);
+ jp.currentLocation(), RDFJSONParserSettings.FAIL_ON_UNKNOWN_PROPERTY);
}
}
@@ -287,41 +288,41 @@ private void rdfJsonToHandlerInternal(final RDFHandler handler, final ValueFacto
if (nextType == null) {
reportFatalError("No type for object: subject=" + subjStr + " predicate=" + predStr,
- jp.getCurrentLocation());
+ jp.currentLocation());
}
if (nextValue == null) {
reportFatalError("No value for object: subject=" + subjStr + " predicate=" + predStr,
- jp.getCurrentLocation());
+ jp.currentLocation());
}
if (RDFJSONUtility.LITERAL.equals(nextType)) {
if (nextLanguage != null) {
- object = this.createLiteral(nextValue, nextLanguage, null, jp.getCurrentLocation());
+ object = this.createLiteral(nextValue, nextLanguage, null, jp.currentLocation());
} else if (nextDatatype != null) {
object = this.createLiteral(nextValue, null, this.createURI(nextDatatype),
- jp.getCurrentLocation());
+ jp.currentLocation());
} else {
- object = this.createLiteral(nextValue, null, null, jp.getCurrentLocation());
+ object = this.createLiteral(nextValue, null, null, jp.currentLocation());
}
} else if (RDFJSONUtility.BNODE.equals(nextType)) {
if (nextLanguage != null) {
reportFatalError("Language was attached to a blank node object: subject=" + subjStr
- + " predicate=" + predStr, jp.getCurrentLocation());
+ + " predicate=" + predStr, jp.currentLocation());
}
if (nextDatatype != null) {
reportFatalError("Datatype was attached to a blank node object: subject=" + subjStr
- + " predicate=" + predStr, jp.getCurrentLocation());
+ + " predicate=" + predStr, jp.currentLocation());
}
object = createNode(nextValue.substring(2));
} else if (RDFJSONUtility.URI.equals(nextType)) {
if (nextLanguage != null) {
reportFatalError("Language was attached to a uri object: subject=" + subjStr + " predicate="
- + predStr, jp.getCurrentLocation());
+ + predStr, jp.currentLocation());
}
if (nextDatatype != null) {
reportFatalError("Datatype was attached to a uri object: subject=" + subjStr + " predicate="
- + predStr, jp.getCurrentLocation());
+ + predStr, jp.currentLocation());
}
object = vf.createIRI(nextValue);
}
@@ -353,12 +354,12 @@ private void rdfJsonToHandlerInternal(final RDFHandler handler, final ValueFacto
}
if (!foundObject) {
reportFatalError("No object for predicate: subject=" + subjStr + " predicate=" + predStr,
- jp.getCurrentLocation());
+ jp.currentLocation());
}
}
if (!foundPredicate) {
- reportFatalError("No predicate for object: subject=" + subjStr, jp.getCurrentLocation());
+ reportFatalError("No predicate for object: subject=" + subjStr, jp.currentLocation());
}
}
}
@@ -395,13 +396,12 @@ public Collection> getSupportedSettings() {
* @return A newly configured JsonFactory based on the currently enabled settings
*/
private JsonFactory configureNewJsonFactory() {
- JsonFactoryBuilder builder = new JsonFactoryBuilder();
+ var builder = JsonFactory.builder();
// Disable features that may work for most JSON where the field names are
- // in limited supply,
- // but does not work for RDF/JSON where a wide range of URIs are used for
- // subjects and predicates
- builder.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
- builder.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES);
+ // in limited supply, but does not work for RDF/JSON where a wide range of
+ // URIs are used for subjects and predicates
+ builder.disable(TokenStreamFactory.Feature.INTERN_PROPERTY_NAMES);
+ builder.disable(TokenStreamFactory.Feature.CANONICALIZE_PROPERTY_NAMES);
builder.disable(StreamWriteFeature.AUTO_CLOSE_TARGET);
if (getParserConfig().isSet(JSONSettings.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)) {
@@ -429,7 +429,7 @@ private JsonFactory configureNewJsonFactory() {
getParserConfig().get(JSONSettings.ALLOW_UNQUOTED_CONTROL_CHARS));
}
if (getParserConfig().isSet(JSONSettings.ALLOW_UNQUOTED_FIELD_NAMES)) {
- builder.configure(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES,
+ builder.configure(JsonReadFeature.ALLOW_UNQUOTED_PROPERTY_NAMES,
getParserConfig().get(JSONSettings.ALLOW_UNQUOTED_FIELD_NAMES));
}
if (getParserConfig().isSet(JSONSettings.ALLOW_YAML_COMMENTS)) {
diff --git a/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONWriter.java b/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONWriter.java
index 7432772d1d2..65dca6cc165 100644
--- a/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONWriter.java
+++ b/core/rio/rdfjson/src/main/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONWriter.java
@@ -38,14 +38,16 @@
import org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter;
import org.eclipse.rdf4j.rio.helpers.BasicWriterSettings;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonFactoryBuilder;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.StreamWriteFeature;
-import com.fasterxml.jackson.core.util.DefaultIndenter;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Indenter;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.PrettyPrinter;
+import tools.jackson.core.StreamWriteFeature;
+import tools.jackson.core.TokenStreamFactory;
+import tools.jackson.core.json.JsonFactory;
+import tools.jackson.core.util.DefaultIndenter;
+import tools.jackson.core.util.DefaultPrettyPrinter;
+import tools.jackson.core.util.DefaultPrettyPrinter.Indenter;
/**
* {@link RDFWriter} implementation for the RDF/JSON format
@@ -90,13 +92,18 @@ public void startRDF() throws RDFHandlerException {
super.startRDF();
try {
isStreaming = getWriterConfig().get(RDFJSONWriterSettings.ALLOW_MULTIPLE_OBJECT_VALUES);
- jg = configureNewJsonFactory().createGenerator(writer);
+ PrettyPrinter pp = null;
if (getWriterConfig().get(BasicWriterSettings.PRETTY_PRINT)) {
Indenter indenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;
- DefaultPrettyPrinter pp = new DefaultPrettyPrinter().withArrayIndenter(indenter)
- .withObjectIndenter(indenter);
- jg.setPrettyPrinter(pp);
+ pp = new DefaultPrettyPrinter().withArrayIndenter(indenter).withObjectIndenter(indenter);
}
+ final PrettyPrinter finalPp = pp;
+ jg = configureNewJsonFactory().createGenerator(new ObjectWriteContext.Base() {
+ @Override
+ public PrettyPrinter getPrettyPrinter() {
+ return finalPp;
+ }
+ }, writer);
if (isStreaming) {
isEmptyStream = true;
lastWrittenPredicate = null;
@@ -105,7 +112,7 @@ public void startRDF() throws RDFHandlerException {
} else {
graph = new TreeModel();
}
- } catch (final IOException e) {
+ } catch (final JacksonException e) {
throw new RDFHandlerException(e);
}
}
@@ -129,7 +136,7 @@ public void endRDF() throws RDFHandlerException {
jg.close();
writer.flush();
}
- } catch (final IOException e) {
+ } catch (final IOException | JacksonException e) {
throw new RDFHandlerException(e);
}
}
@@ -177,35 +184,33 @@ public void consumeStatement(final Statement statement) throws RDFHandlerExcepti
* @param object The RDF value to serialise
* @param contexts The set of contexts that are relevant to this object, including null contexts as they are found.
* @param jg the {@link JsonGenerator} to write to.
- * @throws IOException
- * @throws JsonGenerationException
+ * @throws JacksonException
*/
- public static void writeObject(final Value object, final Set contexts, final JsonGenerator jg)
- throws JsonGenerationException, IOException {
+ protected static void writeObject(final Value object, final Set contexts, final JsonGenerator jg) {
jg.writeStartObject();
if (object instanceof Literal) {
- jg.writeObjectField(RDFJSONUtility.VALUE, object.stringValue());
+ jg.writeStringProperty(RDFJSONUtility.VALUE, object.stringValue());
- jg.writeObjectField(RDFJSONUtility.TYPE, RDFJSONUtility.LITERAL);
+ jg.writeStringProperty(RDFJSONUtility.TYPE, RDFJSONUtility.LITERAL);
final Literal l = (Literal) object;
if (Literals.isLanguageLiteral(l)) {
- jg.writeObjectField(RDFJSONUtility.LANG, l.getLanguage().orElse(null));
+ jg.writeStringProperty(RDFJSONUtility.LANG, l.getLanguage().orElse(null));
} else {
- jg.writeObjectField(RDFJSONUtility.DATATYPE, l.getDatatype().stringValue());
+ jg.writeStringProperty(RDFJSONUtility.DATATYPE, l.getDatatype().stringValue());
}
} else if (object instanceof BNode) {
- jg.writeObjectField(RDFJSONUtility.VALUE, resourceToString((BNode) object));
+ jg.writeStringProperty(RDFJSONUtility.VALUE, resourceToString((BNode) object));
- jg.writeObjectField(RDFJSONUtility.TYPE, RDFJSONUtility.BNODE);
+ jg.writeStringProperty(RDFJSONUtility.TYPE, RDFJSONUtility.BNODE);
} else if (object instanceof IRI) {
- jg.writeObjectField(RDFJSONUtility.VALUE, resourceToString((IRI) object));
+ jg.writeStringProperty(RDFJSONUtility.VALUE, resourceToString((IRI) object));
- jg.writeObjectField(RDFJSONUtility.TYPE, RDFJSONUtility.URI);
+ jg.writeStringProperty(RDFJSONUtility.TYPE, RDFJSONUtility.URI);
}
if (contexts != null && !contexts.isEmpty() && !(contexts.size() == 1 && contexts.iterator().next() == null)) {
- jg.writeArrayFieldStart(RDFJSONUtility.GRAPHS);
+ jg.writeArrayPropertyStart(RDFJSONUtility.GRAPHS);
for (final Resource nextContext : contexts) {
if (nextContext == null) {
jg.writeNull();
@@ -225,7 +230,7 @@ public static void writeObject(final Value object, final Set contexts,
* @param uriOrBnode The resource to serialise to a string
* @return The string value of the RDF4J resource
*/
- public static String resourceToString(final Resource uriOrBnode) {
+ protected static String resourceToString(final Resource uriOrBnode) {
if (uriOrBnode instanceof IRI) {
return uriOrBnode.stringValue();
} else {
@@ -233,22 +238,13 @@ public static String resourceToString(final Resource uriOrBnode) {
}
}
- public static void modelToRdfJsonInternal(final Model graph, final WriterConfig writerConfig,
- final JsonGenerator jg) throws IOException {
- if (writerConfig.get(BasicWriterSettings.PRETTY_PRINT)) {
- // SES-2011: Always use \n for consistency
- Indenter indenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE;
- // By default Jackson does not pretty print, so enable this unless
- // PRETTY_PRINT setting is disabled
- DefaultPrettyPrinter pp = new DefaultPrettyPrinter().withArrayIndenter(indenter)
- .withObjectIndenter(indenter);
- jg.setPrettyPrinter(pp);
- }
+ protected static void modelToRdfJsonInternal(final Model graph, final WriterConfig writerConfig,
+ final JsonGenerator jg) {
jg.writeStartObject();
for (final Resource nextSubject : graph.subjects()) {
- jg.writeObjectFieldStart(RDFJSONWriter.resourceToString(nextSubject));
+ jg.writeObjectPropertyStart(RDFJSONWriter.resourceToString(nextSubject));
for (final IRI nextPredicate : graph.filter(nextSubject, null, null).predicates()) {
- jg.writeArrayFieldStart(nextPredicate.stringValue());
+ jg.writeArrayPropertyStart(nextPredicate.stringValue());
for (final Value nextObject : graph.filter(nextSubject, nextPredicate, null).objects()) {
// contexts are optional, so this may return empty in some
// scenarios depending on the interpretation of the way contexts
@@ -270,16 +266,14 @@ public static void modelToRdfJsonInternal(final Model graph, final WriterConfig
* @return A newly configured JsonFactory based on the currently enabled settings
*/
private JsonFactory configureNewJsonFactory() {
- JsonFactoryBuilder builder = new JsonFactoryBuilder();
- // Disable features that may work for most JSON where the field names are
- // in limited supply,
- // but does not work for RDF/JSON where a wide range of URIs are used for
- // subjects and predicates
- builder.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
- builder.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES);
- builder.disable(StreamWriteFeature.AUTO_CLOSE_TARGET);
-
- return builder.build();
+ return JsonFactory.builder()
+ // Disable features that may work for most JSON where the field names are
+ // in limited supply, but does not work for RDF/JSON where a wide range of
+ // URIs are used for subjects and predicates
+ .disable(TokenStreamFactory.Feature.INTERN_PROPERTY_NAMES)
+ .disable(TokenStreamFactory.Feature.CANONICALIZE_PROPERTY_NAMES)
+ .disable(StreamWriteFeature.AUTO_CLOSE_TARGET)
+ .build();
}
/**
@@ -300,7 +294,7 @@ private void consumeStreamingStatement(final Statement statement) throws RDFHand
lastWrittenPredicate = null;
}
- jg.writeObjectFieldStart(RDFJSONWriter.resourceToString(subj));
+ jg.writeObjectPropertyStart(RDFJSONWriter.resourceToString(subj));
lastWrittenSubject = subj;
}
@@ -310,7 +304,7 @@ private void consumeStreamingStatement(final Statement statement) throws RDFHand
jg.writeEndArray();
}
- jg.writeArrayFieldStart(pred.stringValue());
+ jg.writeArrayPropertyStart(pred.stringValue());
lastWrittenPredicate = pred;
}
@@ -318,7 +312,7 @@ private void consumeStreamingStatement(final Statement statement) throws RDFHand
if (isEmptyStream) {
isEmptyStream = false;
}
- } catch (final IOException e) {
+ } catch (final JacksonException e) {
throw new RDFHandlerException(e);
}
}
diff --git a/core/rio/rdfjson/src/test/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParserCustomTest.java b/core/rio/rdfjson/src/test/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParserCustomTest.java
index efbeacd6f9b..6a1bd07a35f 100644
--- a/core/rio/rdfjson/src/test/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParserCustomTest.java
+++ b/core/rio/rdfjson/src/test/java/org/eclipse/rdf4j/rio/rdfjson/RDFJSONParserCustomTest.java
@@ -38,8 +38,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.io.ContentReference;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.io.ContentReference;
/**
* Custom (non-manifest) tests for RDF/JSON parser.
@@ -148,7 +148,7 @@ public void testSupportedSettings() {
public void testAllowBackslashEscapingAnyCharacterDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(BACKSLASH_ESCAPED_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 5]");
+ .hasMessage("Found exception during parsing [line 1, column 5]");
}
@Test
@@ -163,14 +163,14 @@ public void testAllowBackslashEscapingAnyCharacterDisabled() {
parser.set(JSONSettings.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, false);
assertThatThrownBy(() -> parser.parse(new StringReader(BACKSLASH_ESCAPED_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 5]");
+ .hasMessage("Found exception during parsing [line 1, column 5]");
}
@Test
public void testAllowCommentsDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(COMMENTS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 3]");
+ .hasMessage("Found exception during parsing [line 1, column 3]");
}
@Test
@@ -185,14 +185,14 @@ public void testAllowCommentsDisabled() {
parser.set(JSONSettings.ALLOW_COMMENTS, false);
assertThatThrownBy(() -> parser.parse(new StringReader(COMMENTS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 3]");
+ .hasMessage("Found exception during parsing [line 1, column 3]");
}
@Test
public void testAllowNonNumericNumbersDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(NON_NUMERIC_NUMBERS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 74]");
+ .hasMessage("Found exception during parsing [line 1, column 74]");
}
@Test
@@ -207,14 +207,14 @@ public void testAllowNonNumericNumbersDisabled() {
parser.set(JSONSettings.ALLOW_NON_NUMERIC_NUMBERS, false);
assertThatThrownBy(() -> parser.parse(new StringReader(NON_NUMERIC_NUMBERS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 74]");
+ .hasMessage("Found exception during parsing [line 1, column 74]");
}
@Test
public void testAllowNumericLeadingZeroesDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(NUMERIC_LEADING_ZEROES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 72]");
+ .hasMessage("Found exception during parsing [line 1, column 72]");
}
@Test
@@ -229,14 +229,14 @@ public void testAllowNumericLeadingZeroesDisabled() {
parser.set(JSONSettings.ALLOW_NUMERIC_LEADING_ZEROS, false);
assertThatThrownBy(() -> parser.parse(new StringReader(NUMERIC_LEADING_ZEROES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 72]");
+ .hasMessage("Found exception during parsing [line 1, column 72]");
}
@Test
public void testAllowSingleQuotesDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(SINGLE_QUOTES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 3]");
+ .hasMessage("Found exception during parsing [line 1, column 3]");
}
@Test
@@ -251,14 +251,14 @@ public void testAllowSingleQuotesDisabled() {
parser.set(JSONSettings.ALLOW_SINGLE_QUOTES, false);
assertThatThrownBy(() -> parser.parse(new StringReader(SINGLE_QUOTES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 3]");
+ .hasMessage("Found exception during parsing [line 1, column 3]");
}
@Test
public void testAllowUnquotedControlCharactersDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(UNQUOTED_CONTROL_CHARS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 75]");
+ .hasMessage("Found exception during parsing [line 1, column 75]");
}
@Test
@@ -273,14 +273,14 @@ public void testAllowUnquotedControlCharactersDisabled() {
parser.set(JSONSettings.ALLOW_UNQUOTED_CONTROL_CHARS, false);
assertThatThrownBy(() -> parser.parse(new StringReader(UNQUOTED_CONTROL_CHARS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 75]");
+ .hasMessage("Found exception during parsing [line 1, column 75]");
}
@Test
public void testAllowUnquotedFieldNamesDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(UNQUOTED_FIELD_NAMES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 63]");
+ .hasMessage("Found exception during parsing [line 1, column 63]");
}
@Test
@@ -295,14 +295,14 @@ public void testAllowUnquotedFieldNamesDisabled() {
parser.set(JSONSettings.ALLOW_UNQUOTED_FIELD_NAMES, false);
assertThatThrownBy(() -> parser.parse(new StringReader(UNQUOTED_FIELD_NAMES_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 63]");
+ .hasMessage("Found exception during parsing [line 1, column 63]");
}
@Test
public void testAllowYamlCommentsDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(YAML_COMMENTS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 2, column 2]");
+ .hasMessage("Found exception during parsing [line 2, column 2]");
}
@Test
@@ -317,14 +317,14 @@ public void testAllowYamlCommentsDisabled() {
parser.set(JSONSettings.ALLOW_YAML_COMMENTS, false);
assertThatThrownBy(() -> parser.parse(new StringReader(YAML_COMMENTS_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 2, column 2]");
+ .hasMessage("Found exception during parsing [line 2, column 2]");
}
@Test
public void testAllowTrailingCommaDefault() {
assertThatThrownBy(() -> parser.parse(new StringReader(TRAILING_COMMA_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 113]");
+ .hasMessage("Found exception during parsing [line 1, column 113]");
}
@Test
@@ -339,7 +339,7 @@ public void testAllowTrailingCommaDisabled() {
parser.set(JSONSettings.ALLOW_TRAILING_COMMA, false);
assertThatThrownBy(() -> parser.parse(new StringReader(TRAILING_COMMA_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 113]");
+ .hasMessage("Found exception during parsing [line 1, column 113]");
}
@Test
@@ -350,8 +350,8 @@ public void testIncludeSourceLocationDefault() throws Exception {
fail("Expected to find an exception");
} catch (RDFParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
if (ContentReference.unknown().equals(cause.getLocation().contentReference())) {
assertEquals(ContentReference.unknown(), cause.getLocation().contentReference());
@@ -370,8 +370,8 @@ public void testIncludeSourceLocationEnabled() throws Exception {
fail("Expected to find an exception");
} catch (RDFParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
assertNotEquals(ContentReference.unknown(), cause.getLocation().contentReference());
assertEquals(source, cause.getLocation().contentReference().getRawContent());
@@ -386,8 +386,8 @@ public void testIncludeSourceLocationDisabled() throws Exception {
fail("Expected to find an exception");
} catch (RDFParseException e) {
assertNotNull(e.getCause());
- assertTrue(e.getCause() instanceof JsonProcessingException);
- JsonProcessingException cause = (JsonProcessingException) e.getCause();
+ assertTrue(e.getCause() instanceof JacksonException);
+ JacksonException cause = (JacksonException) e.getCause();
assertTrue(cause.getMessage().contains("Unexpected character ('#' (code 35))"));
assertEquals(ContentReference.unknown(), cause.getLocation().contentReference());
}
@@ -408,7 +408,7 @@ public void testStrictDuplicateDetectionEnabled() {
parser.set(JSONSettings.STRICT_DUPLICATE_DETECTION, true);
assertThatThrownBy(() -> parser.parse(new StringReader(STRICT_DUPLICATE_DETECTION_TEST_STRING), ""))
.isInstanceOf(RDFParseException.class)
- .hasMessage("Found IOException during parsing [line 1, column 119]");
+ .hasMessage("Found exception during parsing [line 1, column 119]");
}
@Test
diff --git a/core/sail/elasticsearch-store/pom.xml b/core/sail/elasticsearch-store/pom.xml
index 9c8633a8779..3b868c7c56e 100644
--- a/core/sail/elasticsearch-store/pom.xml
+++ b/core/sail/elasticsearch-store/pom.xml
@@ -14,6 +14,10 @@
co.elastic.clients
elasticsearch-java
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
org.slf4j
jcl-over-slf4j
diff --git a/core/sail/elasticsearch/pom.xml b/core/sail/elasticsearch/pom.xml
index de9df51da30..5f0270439a7 100644
--- a/core/sail/elasticsearch/pom.xml
+++ b/core/sail/elasticsearch/pom.xml
@@ -19,5 +19,9 @@
co.elastic.clients
elasticsearch-java
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
diff --git a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/QueryPlanRetrievalTest.java b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/QueryPlanRetrievalTest.java
index 0478fe7a5ae..f36f8a7643d 100644
--- a/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/QueryPlanRetrievalTest.java
+++ b/core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/QueryPlanRetrievalTest.java
@@ -49,8 +49,8 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.ObjectMapper;
public class QueryPlanRetrievalTest {
diff --git a/core/sail/nativerdf/pom.xml b/core/sail/nativerdf/pom.xml
index 557c816ff80..468d437df02 100644
--- a/core/sail/nativerdf/pom.xml
+++ b/core/sail/nativerdf/pom.xml
@@ -47,8 +47,9 @@
${project.version}
- com.fasterxml.jackson.core
+ tools.jackson.core
jackson-core
+ ${jackson3.version}
org.slf4j
diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWAL.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWAL.java
index 6714ffbf03c..c8c9201cbac 100644
--- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWAL.java
+++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWAL.java
@@ -42,10 +42,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Write-ahead log (WAL) for the ValueStore. The WAL records minted values in append-only segments so they can be
@@ -401,10 +403,10 @@ static int readSegmentSequence(Path path) throws IOException {
// skip CRC
in.readNBytes(4);
JsonFactory factory = new JsonFactory();
- try (JsonParser parser = factory.createParser(jsonBytes)) {
+ try (JsonParser parser = factory.createParser(ObjectReadContext.empty(), jsonBytes)) {
while (parser.nextToken() != JsonToken.END_OBJECT) {
- if (parser.currentToken() == JsonToken.FIELD_NAME) {
- String field = parser.getCurrentName();
+ if (parser.currentToken() == JsonToken.PROPERTY_NAME) {
+ String field = parser.currentName();
parser.nextToken();
if ("segment".equals(field)) {
return parser.getIntValue();
@@ -823,11 +825,11 @@ private void gzipAndDelete(Path src, int lastMintedId) {
private byte[] buildSummaryFrame(int lastMintedId, long crc32Value) throws IOException {
JsonFactory factory = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
- try (JsonGenerator gen = factory.createGenerator(baos)) {
+ try (JsonGenerator gen = factory.createGenerator(ObjectWriteContext.empty(), baos)) {
gen.writeStartObject();
- gen.writeStringField("t", "S");
- gen.writeNumberField("lastId", lastMintedId);
- gen.writeNumberField("crc32", crc32Value & 0xFFFFFFFFL);
+ gen.writeStringProperty("t", "S");
+ gen.writeNumberProperty("lastId", lastMintedId);
+ gen.writeNumberProperty("crc32", crc32Value & 0xFFFFFFFFL);
gen.writeEndObject();
}
baos.write('\n');
@@ -846,15 +848,15 @@ private byte[] buildSummaryFrame(int lastMintedId, long crc32Value) throws IOExc
private void writeHeader(int firstId) throws IOException {
JsonFactory factory = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(256);
- try (JsonGenerator gen = factory.createGenerator(baos)) {
+ try (JsonGenerator gen = factory.createGenerator(ObjectWriteContext.empty(), baos)) {
gen.writeStartObject();
- gen.writeStringField("t", "V");
- gen.writeNumberField("ver", 1);
- gen.writeStringField("store", config.storeUuid());
- gen.writeStringField("engine", "valuestore");
- gen.writeNumberField("created", Instant.now().getEpochSecond());
- gen.writeNumberField("segment", segmentSequence);
- gen.writeNumberField("firstId", firstId);
+ gen.writeStringProperty("t", "V");
+ gen.writeNumberProperty("ver", 1);
+ gen.writeStringProperty("store", config.storeUuid());
+ gen.writeStringProperty("engine", "valuestore");
+ gen.writeNumberProperty("created", Instant.now().getEpochSecond());
+ gen.writeNumberProperty("segment", segmentSequence);
+ gen.writeNumberProperty("firstId", firstId);
gen.writeEndObject();
}
// NDJSON: newline-delimited JSON
@@ -884,16 +886,16 @@ private int checksum(byte[] data, int len) {
private int encodeIntoReusableBuffer(ValueStoreWalRecord record) throws IOException {
jsonBuffer.reset();
- try (JsonGenerator gen = jsonFactory.createGenerator(jsonBuffer)) {
+ try (JsonGenerator gen = jsonFactory.createGenerator(ObjectWriteContext.empty(), jsonBuffer)) {
gen.writeStartObject();
- gen.writeStringField("t", "M");
- gen.writeNumberField("lsn", record.lsn());
- gen.writeNumberField("id", record.id());
- gen.writeStringField("vk", String.valueOf(record.valueKind().code()));
- gen.writeStringField("lex", record.lexical() == null ? "" : record.lexical());
- gen.writeStringField("dt", record.datatype() == null ? "" : record.datatype());
- gen.writeStringField("lang", record.language() == null ? "" : record.language());
- gen.writeNumberField("hash", record.hash());
+ gen.writeStringProperty("t", "M");
+ gen.writeNumberProperty("lsn", record.lsn());
+ gen.writeNumberProperty("id", record.id());
+ gen.writeStringProperty("vk", String.valueOf(record.valueKind().code()));
+ gen.writeStringProperty("lex", record.lexical() == null ? "" : record.lexical());
+ gen.writeStringProperty("dt", record.datatype() == null ? "" : record.datatype());
+ gen.writeStringProperty("lang", record.language() == null ? "" : record.language());
+ gen.writeNumberProperty("hash", record.hash());
gen.writeEndObject();
}
jsonBuffer.write('\n'); // NDJSON newline
diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReader.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReader.java
index 577f848a197..9dd1b571172 100644
--- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReader.java
+++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReader.java
@@ -32,10 +32,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.core.StreamReadConstraints;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.StreamReadConstraints;
+import tools.jackson.core.json.JsonFactory;
/**
* Reader for ValueStore WAL segments that yields minted records in LSN order across segments. It tolerates truncated or
@@ -419,12 +420,12 @@ private void prepareNext() throws IOException {
private Parsed parseJson(byte[] jsonBytes) throws IOException {
Parsed parsed = new Parsed();
- try (JsonParser jp = jsonFactory.createParser(jsonBytes)) {
+ try (JsonParser jp = jsonFactory.createParser(ObjectReadContext.empty(), jsonBytes)) {
if (jp.nextToken() != JsonToken.START_OBJECT) {
return parsed;
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- String field = jp.getCurrentName();
+ String field = jp.currentName();
jp.nextToken();
if ("t".equals(field)) {
String t = jp.getValueAsString("");
diff --git a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearch.java b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearch.java
index d43e8e6f2a2..61105f6b21d 100644
--- a/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearch.java
+++ b/core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearch.java
@@ -31,10 +31,11 @@
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.core.StreamReadConstraints;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.StreamReadConstraints;
+import tools.jackson.core.json.JsonFactory;
/**
* Utility to search a ValueStore WAL for a specific minted value ID efficiently.
@@ -267,12 +268,12 @@ private int readIntLE(InputStream in) throws IOException {
private Parsed parseJson(byte[] jsonBytes) throws IOException {
Parsed parsed = new Parsed();
- try (JsonParser jp = jsonFactory.createParser(jsonBytes)) {
+ try (JsonParser jp = jsonFactory.createParser(ObjectReadContext.empty(), jsonBytes)) {
if (jp.nextToken() != JsonToken.START_OBJECT) {
return parsed;
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- String field = jp.getCurrentName();
+ String field = jp.currentName();
jp.nextToken();
if ("t".equals(field)) {
String t = jp.getValueAsString("");
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/ValueStoreRandomLookupTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/ValueStoreRandomLookupTest.java
index 42da7359c89..4e0835beb43 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/ValueStoreRandomLookupTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/ValueStoreRandomLookupTest.java
@@ -58,9 +58,10 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.json.JsonFactory;
class ValueStoreRandomLookupTest {
@@ -331,7 +332,7 @@ private static final class ParsedRecord {
}
static ParsedRecord parse(byte[] json) throws IOException {
- try (JsonParser parser = JSON_FACTORY.createParser(json)) {
+ try (JsonParser parser = JSON_FACTORY.createParser(ObjectReadContext.empty(), json)) {
char type = '?';
int id = 0;
long crc32 = 0L;
@@ -339,8 +340,8 @@ static ParsedRecord parse(byte[] json) throws IOException {
int segment = 0;
while (parser.nextToken() != null) {
JsonToken token = parser.currentToken();
- if (token == JsonToken.FIELD_NAME) {
- String field = parser.getCurrentName();
+ if (token == JsonToken.PROPERTY_NAME) {
+ String field = parser.currentName();
parser.nextToken();
if ("t".equals(field)) {
String value = parser.getValueAsString("");
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWALReadSegmentSequenceEdgeCasesTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWALReadSegmentSequenceEdgeCasesTest.java
index 376eceb26d3..1cb68fc9c87 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWALReadSegmentSequenceEdgeCasesTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWALReadSegmentSequenceEdgeCasesTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
@Tag("slow")
class ValueStoreWALReadSegmentSequenceEdgeCasesTest {
@@ -76,14 +77,14 @@ void returnsZeroWhenHeaderHasNoSegmentField() throws Exception {
private static byte[] headerWithoutSegment() throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("firstId", 1);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("firstId", 1);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedNoSummaryTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedNoSummaryTest.java
index 6f3729bad96..e88822d0b1c 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedNoSummaryTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedNoSummaryTest.java
@@ -25,8 +25,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Validates that a compressed segment lacking a summary frame results in incomplete scan.
@@ -75,15 +76,15 @@ private static void frame(GZIPOutputStream out, byte[] json) throws IOException
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -93,16 +94,16 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] mintedJson(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", "http://ex/id" + id);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", "http://ex/id" + id);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSegmentRestoreTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSegmentRestoreTest.java
index 6eb7f58a125..bb5fc1f9bd3 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSegmentRestoreTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSegmentRestoreTest.java
@@ -33,9 +33,10 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Restores a value record from a compressed ValueStore WAL segment by performing a binary search on segment first LSNs.
@@ -219,12 +220,12 @@ private static int readIntLE(InputStream in) throws IOException {
private static Parsed parseJson(byte[] jsonBytes) throws IOException {
Parsed parsed = new Parsed();
- try (JsonParser jp = JSON_FACTORY.createParser(jsonBytes)) {
+ try (JsonParser jp = JSON_FACTORY.createParser(ObjectReadContext.empty(), jsonBytes)) {
if (jp.nextToken() != JsonToken.START_OBJECT) {
return parsed;
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
- String field = jp.getCurrentName();
+ String field = jp.currentName();
jp.nextToken();
if ("t".equals(field)) {
String t = jp.getValueAsString("");
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSummaryCrcValidationTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSummaryCrcValidationTest.java
index adfb1e9796b..e642bb64782 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSummaryCrcValidationTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalCompressedSummaryCrcValidationTest.java
@@ -30,10 +30,12 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Validates that ValueStoreWalReader verifies the CRC32 summary embedded in compressed segments and marks the scan as
@@ -119,14 +121,14 @@ private static void corruptSummaryCrc32(Path gz) throws IOException {
pos += 4;
// Parse JSON and detect summary frame
- try (JsonParser jp = new JsonFactory().createParser(json)) {
+ try (JsonParser jp = new JsonFactory().createParser(ObjectReadContext.empty(), json)) {
if (jp.nextToken() != JsonToken.START_OBJECT) {
continue;
}
String type = null;
Integer lid = null;
while (jp.nextToken() != JsonToken.END_OBJECT) {
- String field = jp.getCurrentName();
+ String field = jp.currentName();
jp.nextToken();
if ("t".equals(field)) {
type = jp.getValueAsString("");
@@ -166,11 +168,11 @@ private static void corruptSummaryCrc32(Path gz) throws IOException {
private static byte[] buildSummaryFrameWithCrc(int lastMintedId, long wrongCrc32) throws IOException {
JsonFactory factory = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
- try (JsonGenerator gen = factory.createGenerator(baos)) {
+ try (JsonGenerator gen = factory.createGenerator(ObjectWriteContext.empty(), baos)) {
gen.writeStartObject();
- gen.writeStringField("t", "S");
- gen.writeNumberField("lastId", lastMintedId);
- gen.writeNumberField("crc32", wrongCrc32 & 0xFFFFFFFFL);
+ gen.writeStringProperty("t", "S");
+ gen.writeNumberProperty("lastId", lastMintedId);
+ gen.writeNumberProperty("crc32", wrongCrc32 & 0xFFFFFFFFL);
gen.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReadSegmentSequenceTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReadSegmentSequenceTest.java
index 59c36879582..5ff187936c7 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReadSegmentSequenceTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReadSegmentSequenceTest.java
@@ -25,8 +25,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
@Tag("slow")
class ValueStoreWalReadSegmentSequenceTest {
@@ -61,15 +62,15 @@ void readsSequenceFromCompressed() throws Exception {
private static byte[] buildHeaderFrame(String store, int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", store);
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", store);
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderGzipInvalidAndTruncatedTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderGzipInvalidAndTruncatedTest.java
index b85acc62699..c097799a1f1 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderGzipInvalidAndTruncatedTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderGzipInvalidAndTruncatedTest.java
@@ -24,8 +24,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Tests gzip path for invalid length and truncated CRC conditions.
@@ -103,15 +104,15 @@ private static int crc32c(byte[] data) {
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -121,16 +122,16 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] mintedJson(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", "http://ex/id" + id);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", "http://ex/id" + id);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderHasSequenceGapsTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderHasSequenceGapsTest.java
index 5e4bdd5b7a7..8b393934d3c 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderHasSequenceGapsTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderHasSequenceGapsTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures reader reports incomplete when segment sequences are non-contiguous (e.g., segments 1 and 3 present).
@@ -53,15 +54,15 @@ void sequenceGapsMarkIncomplete() throws Exception {
private static byte[] headerOnly(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderInvalidFrameTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderInvalidFrameTest.java
index e2b6540ce9a..256f715ed67 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderInvalidFrameTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderInvalidFrameTest.java
@@ -24,8 +24,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures the reader marks the scan incomplete when encountering an invalid or oversized frame length.
@@ -64,15 +65,15 @@ void invalidLengthStopsScanAndMarksIncomplete() throws Exception {
private static byte[] headerFrame(String store) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", store);
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", 1);
- g.writeNumberField("firstId", 1);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", store);
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", 1);
+ g.writeNumberProperty("firstId", 1);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderLastLsnNonMintedTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderLastLsnNonMintedTest.java
index aa5972f9106..01bc3824d77 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderLastLsnNonMintedTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderLastLsnNonMintedTest.java
@@ -26,8 +26,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Verifies that encountering non-minted frames (header 'V' and summary 'S') does not alter lastValidLsn; it should
@@ -80,15 +81,15 @@ private static void frame(ByteArrayOutputStream out, byte[] json) {
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -98,16 +99,16 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] mintedJson(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", "http://ex/id" + id);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", "http://ex/id" + id);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
@@ -117,11 +118,11 @@ private static byte[] mintedJson(long lsn, int id) throws IOException {
private static byte[] summaryJson(int lastId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "S");
- g.writeNumberField("lastId", lastId);
- g.writeNumberField("crc32", 0L);
+ g.writeStringProperty("t", "S");
+ g.writeNumberProperty("lastId", lastId);
+ g.writeNumberProperty("crc32", 0L);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderListSegmentsUnreadableTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderListSegmentsUnreadableTest.java
index e28aa2bb4fa..cd7880b776f 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderListSegmentsUnreadableTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderListSegmentsUnreadableTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures listSegments tolerates unreadable/mis-typed entries that match the filename pattern by creating a directory
@@ -58,15 +59,15 @@ void unreadableSegmentHeaderIsTolerated() throws Exception {
private static byte[] headerFrame(int seq, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", seq);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", seq);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderParseJsonSkipChildrenTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderParseJsonSkipChildrenTest.java
index eabbb0be712..831e0426889 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderParseJsonSkipChildrenTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderParseJsonSkipChildrenTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Crafts a minted frame with an extra nested object field to exercise parseJson's skipChildren branch.
@@ -66,15 +67,15 @@ void mintedWithExtraNestedObjectIsParsedAndIgnored() throws Exception {
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -84,19 +85,19 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] mintedJsonWithExtra(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", "http://ex/id" + id);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", "http://ex/id" + id);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
// Extra nested object to trigger skipChildren
- g.writeObjectFieldStart("x");
- g.writeNumberField("a", 1);
+ g.writeObjectPropertyStart("x");
+ g.writeNumberProperty("a", 1);
g.writeEndObject();
g.writeEndObject();
}
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderTruncatedRecordTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderTruncatedRecordTest.java
index dd051d0daf6..561bd62f6a0 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderTruncatedRecordTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderTruncatedRecordTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures the reader marks incomplete when a frame is truncated (length OK, payload/CRC missing).
@@ -61,15 +62,15 @@ void truncatedFrameMarksIncomplete() throws Exception {
private static byte[] headerFrame() throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", 1);
- g.writeNumberField("firstId", 1);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", 1);
+ g.writeNumberProperty("firstId", 1);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedCrcMismatchTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedCrcMismatchTest.java
index 691688b0880..be74b45545a 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedCrcMismatchTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedCrcMismatchTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures uncompressed reader stops and marks incomplete when CRC32C mismatches.
@@ -75,15 +76,15 @@ private static int crc32c(byte[] data) {
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -93,16 +94,16 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] mintedJson(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", "http://ex/id" + id);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", "http://ex/id" + id);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedTest.java
index 3ff48bd7609..c064bd9db5f 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUncompressedTest.java
@@ -27,8 +27,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Exercises ValueStoreWalReader's uncompressed path by writing a minimal .v1 segment by hand and verifying iteration.
@@ -99,15 +100,15 @@ private static void frame(ByteArrayOutputStream out, byte[] json) {
private static byte[] headerJson(String store, int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", store);
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", store);
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -118,16 +119,16 @@ private static byte[] mintedJson(long lsn, int id, String vk, String lex, String
throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", vk);
- g.writeStringField("lex", lex == null ? "" : lex);
- g.writeStringField("dt", dt == null ? "" : dt);
- g.writeStringField("lang", lang == null ? "" : lang);
- g.writeNumberField("hash", hash);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", vk);
+ g.writeStringProperty("lex", lex == null ? "" : lex);
+ g.writeStringProperty("dt", dt == null ? "" : dt);
+ g.writeStringProperty("lang", lang == null ? "" : lang);
+ g.writeNumberProperty("hash", hash);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUnknownValueKindTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUnknownValueKindTest.java
index 4a72cd57489..88e1c8f2012 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUnknownValueKindTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalReaderUnknownValueKindTest.java
@@ -23,8 +23,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Verifies that encountering an unknown value kind code causes parsing to fail with IllegalArgumentException.
@@ -74,15 +75,15 @@ private static int crc32c(byte[] data) {
private static byte[] headerJson(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -92,16 +93,16 @@ private static byte[] headerJson(int segment, int firstId) throws IOException {
private static byte[] invalidMintedJson(long lsn, int id) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "?"); // invalid code
- g.writeStringField("lex", "x");
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "?"); // invalid code
+ g.writeStringProperty("lex", "x");
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalRecoveryDedupTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalRecoveryDedupTest.java
index 02a7aa11d4a..02fb9179229 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalRecoveryDedupTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalRecoveryDedupTest.java
@@ -24,8 +24,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Ensures ValueStoreWalRecovery keeps the first occurrence of a duplicated id encountered across segments.
@@ -68,15 +69,15 @@ private static byte[] segmentBytes(int segment, int id, String lex) throws IOExc
private static byte[] header(int segment, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", segment);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", segment);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -86,16 +87,16 @@ private static byte[] header(int segment, int firstId) throws IOException {
private static byte[] minted(long lsn, int id, String lex) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", lsn);
- g.writeNumberField("id", id);
- g.writeStringField("vk", "I");
- g.writeStringField("lex", lex);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", lsn);
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", "I");
+ g.writeStringProperty("lex", lex);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearchEdgeCasesTest.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearchEdgeCasesTest.java
index 4803f4f262b..a8ed1a95796 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearchEdgeCasesTest.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalSearchEdgeCasesTest.java
@@ -26,8 +26,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.core.json.JsonFactory;
@Tag("slow")
class ValueStoreWalSearchEdgeCasesTest {
@@ -84,15 +85,15 @@ private static byte[] segmentWithTwoIds(int seq, int firstId, int id1, int id2)
private static byte[] header(int seq, int firstId) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "V");
- g.writeNumberField("ver", 1);
- g.writeStringField("store", "s");
- g.writeStringField("engine", "valuestore");
- g.writeNumberField("created", 0);
- g.writeNumberField("segment", seq);
- g.writeNumberField("firstId", firstId);
+ g.writeStringProperty("t", "V");
+ g.writeNumberProperty("ver", 1);
+ g.writeStringProperty("store", "s");
+ g.writeStringProperty("engine", "valuestore");
+ g.writeNumberProperty("created", 0);
+ g.writeNumberProperty("segment", seq);
+ g.writeNumberProperty("firstId", firstId);
g.writeEndObject();
}
baos.write('\n');
@@ -102,16 +103,16 @@ private static byte[] header(int seq, int firstId) throws IOException {
private static byte[] minted(int id, String vk, String lex) throws IOException {
JsonFactory f = new JsonFactory();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (JsonGenerator g = f.createGenerator(baos)) {
+ try (JsonGenerator g = f.createGenerator(ObjectWriteContext.empty(), baos)) {
g.writeStartObject();
- g.writeStringField("t", "M");
- g.writeNumberField("lsn", id); // monotonic for simplicity
- g.writeNumberField("id", id);
- g.writeStringField("vk", vk);
- g.writeStringField("lex", lex);
- g.writeStringField("dt", "");
- g.writeStringField("lang", "");
- g.writeNumberField("hash", 0);
+ g.writeStringProperty("t", "M");
+ g.writeNumberProperty("lsn", id); // monotonic for simplicity
+ g.writeNumberProperty("id", id);
+ g.writeStringProperty("vk", vk);
+ g.writeStringProperty("lex", lex);
+ g.writeStringProperty("dt", "");
+ g.writeStringProperty("lang", "");
+ g.writeNumberProperty("hash", 0);
g.writeEndObject();
}
baos.write('\n');
diff --git a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalTestUtils.java b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalTestUtils.java
index c7e8bc1a2f8..bdb5206de87 100644
--- a/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalTestUtils.java
+++ b/core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/wal/ValueStoreWalTestUtils.java
@@ -20,9 +20,10 @@
import java.nio.file.Path;
import java.util.zip.GZIPInputStream;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.core.ObjectReadContext;
+import tools.jackson.core.json.JsonFactory;
/**
* Test utility helpers for inspecting ValueStore WAL segments.
@@ -64,10 +65,10 @@ private static int readSegmentSequence(InputStream in) throws IOException {
}
// Skip header CRC
in.readNBytes(Integer.BYTES);
- try (JsonParser parser = JSON_FACTORY.createParser(jsonBytes)) {
+ try (JsonParser parser = JSON_FACTORY.createParser(ObjectReadContext.empty(), jsonBytes)) {
while (parser.nextToken() != JsonToken.END_OBJECT) {
- if (parser.currentToken() == JsonToken.FIELD_NAME) {
- String field = parser.getCurrentName();
+ if (parser.currentToken() == JsonToken.PROPERTY_NAME) {
+ String field = parser.currentName();
parser.nextToken();
if ("segment".equals(field)) {
return parser.getIntValue();
diff --git a/pom.xml b/pom.xml
index a9e3d0b18bb..99fffb00706 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
5.3.4
2.21.0
2.21
+ 3.1.2
4.4.16
0.13.4
6.0.0
diff --git a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/DeleteServlet.java b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/DeleteServlet.java
index 74a61a0cd6d..1b94a6a0e5a 100644
--- a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/DeleteServlet.java
+++ b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/DeleteServlet.java
@@ -22,10 +22,9 @@
import org.eclipse.rdf4j.workbench.util.TupleResultBuilder;
import org.eclipse.rdf4j.workbench.util.WorkbenchRequest;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
import jakarta.servlet.http.HttpServletResponse;
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.node.ObjectNode;
/**
* Servlet responsible for presenting the list of repositories, and deleting the chosen one.
diff --git a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/QueryServlet.java b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/QueryServlet.java
index e12630faa39..d9bdfe2e749 100644
--- a/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/QueryServlet.java
+++ b/tools/workbench/src/main/java/org/eclipse/rdf4j/workbench/commands/QueryServlet.java
@@ -57,13 +57,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.node.ObjectNode;
public class QueryServlet extends TransformationServlet {