Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Add warmup phase to wait for lag to catch up in pull-based ingestion before serving ([#20526](https://github.com/opensearch-project/OpenSearch/pull/20526))
- Add a new static method to IndicesOptions API to expose `STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED` index option ([#20980](https://github.com/opensearch-project/OpenSearch/pull/20980))
- Support Jackson 3.x release line ([#21029](https://github.com/opensearch-project/OpenSearch/pull/21029))

### Changed
- Make telemetry `Tags` immutable ([#20788](https://github.com/opensearch-project/OpenSearch/pull/20788))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

package org.opensearch.client;

import com.fasterxml.jackson.core.JsonParseException;

import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentType;
Expand Down Expand Up @@ -86,6 +84,7 @@
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.rest.yaml.restspec.ClientYamlSuiteRestApi;
import org.opensearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec;
import org.opensearch.tools.jackson.core.JsonParseException;
import org.hamcrest.Matchers;
import org.junit.Before;

Expand Down
2 changes: 1 addition & 1 deletion client/sniffer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {
api "org.apache.httpcomponents.core5:httpcore5:${versions.httpcore5}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api "commons-logging:commons-logging:${versions.commonslogging}"
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api "tools.jackson.core:jackson-core:${versions.jackson3}"

testImplementation project(":client:test")
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
Expand Down
1 change: 0 additions & 1 deletion client/sniffer/licenses/jackson-core-2.21.2.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions client/sniffer/licenses/jackson-core-3.1.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
df0dc5d0bf720739ae7b6afeee2af2aabf88905b
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@

package org.opensearch.client.sniff;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hc.core5.http.HttpEntity;
Expand All @@ -60,6 +56,10 @@
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;

import tools.jackson.core.JsonParser;
import tools.jackson.core.JsonToken;
import tools.jackson.core.json.JsonFactory;

import static java.util.Collections.singletonList;
import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableMap;
Expand Down Expand Up @@ -131,12 +131,12 @@ static List<Node> readHosts(HttpEntity entity, Scheme scheme, JsonFactory jsonFa
}
List<Node> nodes = new ArrayList<>();
while (parser.nextToken() != JsonToken.END_OBJECT) {
if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
if ("nodes".equals(parser.getCurrentName())) {
if (parser.currentToken() == JsonToken.START_OBJECT) {
if ("nodes".equals(parser.currentName())) {
while (parser.nextToken() != JsonToken.END_OBJECT) {
JsonToken token = parser.nextToken();
assert token == JsonToken.START_OBJECT;
String nodeId = parser.getCurrentName();
String nodeId = parser.currentName();
Node node = readNode(nodeId, parser, scheme);
if (node != null) {
nodes.add(node);
Expand Down Expand Up @@ -174,12 +174,12 @@ private static Node readNode(String nodeId, JsonParser parser, Scheme scheme) th

String fieldName = null;
while (parser.nextToken() != JsonToken.END_OBJECT) {
if (parser.getCurrentToken() == JsonToken.FIELD_NAME) {
fieldName = parser.getCurrentName();
} else if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
if (parser.currentToken() == JsonToken.PROPERTY_NAME) {
fieldName = parser.currentName();
} else if (parser.currentToken() == JsonToken.START_OBJECT) {
if ("http".equals(fieldName)) {
while (parser.nextToken() != JsonToken.END_OBJECT) {
if (parser.getCurrentToken() == JsonToken.VALUE_STRING && "publish_address".equals(parser.getCurrentName())) {
if (parser.currentToken() == JsonToken.VALUE_STRING && "publish_address".equals(parser.currentName())) {
String address = parser.getValueAsString();
String host;
URI publishAddressAsURI;
Expand All @@ -194,23 +194,23 @@ private static Node readNode(String nodeId, JsonParser parser, Scheme scheme) th
host = publishAddressAsURI.getHost();
}
publishedHost = new HttpHost(publishAddressAsURI.getScheme(), host, publishAddressAsURI.getPort());
} else if (parser.currentToken() == JsonToken.START_ARRAY && "bound_address".equals(parser.getCurrentName())) {
} else if (parser.currentToken() == JsonToken.START_ARRAY && "bound_address".equals(parser.currentName())) {
while (parser.nextToken() != JsonToken.END_ARRAY) {
URI boundAddressAsURI = URI.create(scheme + "://" + parser.getValueAsString());
boundHosts.add(
new HttpHost(boundAddressAsURI.getScheme(), boundAddressAsURI.getHost(), boundAddressAsURI.getPort())
);
}
} else if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
} else if (parser.currentToken() == JsonToken.START_OBJECT) {
parser.skipChildren();
}
}
} else if ("attributes".equals(fieldName)) {
while (parser.nextToken() != JsonToken.END_OBJECT) {
if (parser.getCurrentToken() == JsonToken.VALUE_STRING) {
String oldValue = protoAttributes.put(parser.getCurrentName(), parser.getValueAsString());
if (parser.currentToken() == JsonToken.VALUE_STRING) {
String oldValue = protoAttributes.put(parser.currentName(), parser.getValueAsString());
if (oldValue != null) {
throw new IOException("repeated attribute key [" + parser.getCurrentName() + "]");
throw new IOException("repeated attribute key [" + parser.currentName() + "]");
}
} else {
parser.skipChildren();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

package org.opensearch.client.sniff;

import com.fasterxml.jackson.core.JsonFactory;

import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
Expand All @@ -53,6 +51,8 @@
import java.util.Set;
import java.util.TreeSet;

import tools.jackson.core.json.JsonFactory;

import static java.util.Collections.singletonList;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
Expand Down Expand Up @@ -69,6 +66,9 @@
import java.util.Set;
import java.util.TreeSet;

import tools.jackson.core.JsonGenerator;
import tools.jackson.core.json.JsonFactory;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.startsWith;
Expand Down Expand Up @@ -202,13 +202,13 @@ private static SniffResponse buildSniffResponse(OpenSearchNodesSniffer.Scheme sc
JsonGenerator generator = jsonFactory.createGenerator(writer);
generator.writeStartObject();
if (getRandom().nextBoolean()) {
generator.writeStringField("cluster_name", "opensearch");
generator.writeStringProperty("cluster_name", "opensearch");
}
if (getRandom().nextBoolean()) {
generator.writeObjectFieldStart("bogus_object");
generator.writeObjectPropertyStart("bogus_object");
generator.writeEndObject();
}
generator.writeObjectFieldStart("nodes");
generator.writeObjectPropertyStart("nodes");
for (int i = 0; i < numNodes; i++) {
String nodeId = RandomStrings.randomAsciiOfLengthBetween(getRandom(), 5, 10);
String host = "host" + i;
Expand Down Expand Up @@ -255,40 +255,40 @@ private static SniffResponse buildSniffResponse(OpenSearchNodesSniffer.Scheme sc
attributes
);

generator.writeObjectFieldStart(nodeId);
generator.writeObjectPropertyStart(nodeId);
if (getRandom().nextBoolean()) {
generator.writeObjectFieldStart("bogus_object");
generator.writeObjectPropertyStart("bogus_object");
generator.writeEndObject();
}
if (getRandom().nextBoolean()) {
generator.writeArrayFieldStart("bogus_array");
generator.writeArrayPropertyStart("bogus_array");
generator.writeStartObject();
generator.writeEndObject();
generator.writeEndArray();
}
boolean isHttpEnabled = rarely() == false;
if (isHttpEnabled) {
nodes.add(node);
generator.writeObjectFieldStart("http");
generator.writeArrayFieldStart("bound_address");
generator.writeObjectPropertyStart("http");
generator.writeArrayPropertyStart("bound_address");
for (HttpHost bound : boundHosts) {
generator.writeString(bound.toHostString());
}
generator.writeEndArray();
if (getRandom().nextBoolean()) {
generator.writeObjectFieldStart("bogus_object");
generator.writeObjectPropertyStart("bogus_object");
generator.writeEndObject();
}
generator.writeStringField("publish_address", publishHost.toHostString());
generator.writeStringProperty("publish_address", publishHost.toHostString());
if (getRandom().nextBoolean()) {
generator.writeNumberField("max_content_length_in_bytes", 104857600);
generator.writeNumberProperty("max_content_length_in_bytes", 104857600);
}
generator.writeEndObject();
}

List<String> roles = Arrays.asList(new String[] { "cluster_manager", "data", "ingest" });
Collections.shuffle(roles, getRandom());
generator.writeArrayFieldStart("roles");
generator.writeArrayPropertyStart("roles");
for (String role : roles) {
if ("cluster_manager".equals(role) && node.getRoles().isClusterManagerEligible()) {
generator.writeString("cluster_manager");
Expand All @@ -302,15 +302,15 @@ private static SniffResponse buildSniffResponse(OpenSearchNodesSniffer.Scheme sc
}
generator.writeEndArray();

generator.writeFieldName("version");
generator.writeName("version");
generator.writeString(node.getVersion());
generator.writeFieldName("name");
generator.writeName("name");
generator.writeString(node.getName());

if (numAttributes > 0) {
generator.writeObjectFieldStart("attributes");
generator.writeObjectPropertyStart("attributes");
for (Map.Entry<String, List<String>> entry : attributes.entrySet()) {
generator.writeStringField(entry.getKey(), entry.getValue().toString());
generator.writeStringProperty(entry.getKey(), entry.getValue().toString());
}
generator.writeEndObject();
}
Expand Down
14 changes: 13 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jts = "1.15.0"
jackson_annotations = "2.21"
jackson = "2.21.2"
jackson_databind = "2.21.2"
snakeyaml = "2.1"
jackson3 = "3.1.0"
jackson3_databind = "3.1.0"
snakeyaml = "2.6"
snakeyaml_engine = "3.0.1"
icu4j = "77.1"
supercsv = "2.4.0"
log4j = "2.25.3"
Expand Down Expand Up @@ -117,8 +120,17 @@ gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version.ref = "hamcrest" }
hdrhistogram = { group = "org.hdrhistogram", name = "HdrHistogram", version.ref = "hdrhistogram" }
jackson-annotation = { group = "com.fasterxml.jackson.core", name = "jackson-annotations", version.ref = "jackson_annotations" }
jackson-core = { group = "com.fasterxml.jackson.core", name = "jackson-core", version.ref = "jackson" }
jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson_databind" }
jackson-dataformat-smile = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-smile", version.ref = "jackson" }
jackson-dataformat-yaml = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson" }
jackson-dataformat-cbor = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-cbor", version.ref = "jackson" }
jackson-datatype-jsr310 = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-jsr310", version.ref = "jackson" }
jackson3-core = { group = "tools.jackson.core", name = "jackson-core", version.ref = "jackson3" }
jackson3-databind = { group = "tools.jackson.core", name = "jackson-databind", version.ref = "jackson3_databind" }
jackson3-dataformat-smile = { group = "tools.jackson.dataformat", name = "jackson-dataformat-smile", version.ref = "jackson3" }
jackson3-dataformat-yaml = { group = "tools.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson3" }
jackson3-dataformat-cbor = { group = "tools.jackson.dataformat", name = "jackson-dataformat-cbor", version.ref = "jackson3" }
jakartaannotation = { group = "jakarta.annotation", name = "jakarta.annotation-api", version.ref = "jakarta_annotation" }
jodatime = { group = "joda-time", name = "joda-time", version.ref = "joda" }
jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" }
Expand Down
2 changes: 1 addition & 1 deletion libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ base {
dependencies {
api project(':libs:opensearch-common')

api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api libs.jackson3.core

// lucene
api "org.apache.lucene:lucene-core:${versions.lucene}"
Expand Down
1 change: 0 additions & 1 deletion libs/core/licenses/jackson-core-2.21.2.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions libs/core/licenses/jackson-core-3.1.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
df0dc5d0bf720739ae7b6afeee2af2aabf88905b
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

package org.opensearch;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.exc.InputCoercionException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.index.CorruptIndexException;
Expand All @@ -48,6 +45,8 @@
import org.opensearch.core.concurrency.OpenSearchRejectedExecutionException;
import org.opensearch.core.index.Index;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.tools.jackson.core.InputCoercionException;
import org.opensearch.tools.jackson.core.JsonParseException;

import java.io.IOException;
import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,10 @@ private static String toString(MediaType mediaType, ToXContent toXContent, ToXCo
private static XContentBuilder createBuilder(MediaType mediaType, boolean pretty, boolean human) throws IOException {
XContentBuilder builder = XContentBuilder.builder(mediaType.xContent());
if (pretty) {
builder.prettyPrint();
builder = builder.prettyPrint();
}
if (human) {
builder.humanReadable(true);
builder = builder.humanReadable(true);
}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ default XContentGenerator createGenerator(OutputStream os) throws IOException {
return createGenerator(os, Collections.emptySet(), Collections.emptySet());
}

/**
* Creates a new generator using the provided output stream.
*/
default XContentGenerator createGenerator(OutputStream os, boolean prettyPrint) throws IOException {
return createGenerator(os, Collections.emptySet(), Collections.emptySet(), prettyPrint);
}

/**
* Creates a new generator using the provided output stream and some inclusive and/or exclusive filters. When both exclusive and
* inclusive filters are provided, the underlying generator will first use exclusion filters to remove fields and then will check the
* remaining fields against the inclusive filters.
*
* @param os the output stream
* @param includes the inclusive filters: only fields and objects that match the inclusive filters will be written to the output.
* @param excludes the exclusive filters: only fields and objects that don't match the exclusive filters will be written to the output.
*/
default XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException {
return createGenerator(os, includes, excludes, false);
}

/**
* Creates a new generator using the provided output stream and some inclusive and/or exclusive filters. When both exclusive and
* inclusive filters are provided, the underlying generator will first use exclusion filters to remove fields and then will check the
Expand All @@ -70,8 +90,9 @@ default XContentGenerator createGenerator(OutputStream os) throws IOException {
* @param os the output stream
* @param includes the inclusive filters: only fields and objects that match the inclusive filters will be written to the output.
* @param excludes the exclusive filters: only fields and objects that don't match the exclusive filters will be written to the output.
* @param prettyPrint use pretty printer
*/
XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException;
XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes, boolean prettyPrint) throws IOException;

/**
* Creates a parser over the provided string content.
Expand Down
Loading
Loading