From 2a73127c692dfab35fd3917a6b64e3502fdc8f68 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Thu, 19 Oct 2017 15:15:02 +0200 Subject: [PATCH] Upgrade to Jackson 2.9.2 (#27032) Upgrade to Jackson 2.9.2 and also use a boolean `closed` flag to indicate that a FastStringReader instance is closed, so that length is still correctly reported after the reader is closed. --- buildSrc/version.properties | 4 ++-- client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 | 1 - client/sniffer/licenses/jackson-core-2.9.2.jar.sha1 | 1 + core/licenses/jackson-core-2.8.6.jar.sha1 | 1 - core/licenses/jackson-core-2.9.2.jar.sha1 | 1 + core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 | 1 - core/licenses/jackson-dataformat-cbor-2.9.2.jar.sha1 | 1 + core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 | 1 - core/licenses/jackson-dataformat-smile-2.9.2.jar.sha1 | 1 + core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 | 1 - core/licenses/jackson-dataformat-yaml-2.9.2.jar.sha1 | 1 + core/licenses/snakeyaml-1.15.jar.sha1 | 1 - core/licenses/snakeyaml-1.18.jar.sha1 | 1 + .../org/elasticsearch/common/io/FastStringReader.java | 9 ++++----- .../elasticsearch/rest/action/RestActionsTests.java | 10 +++++----- .../ingest/common/JsonProcessorTests.java | 2 +- 16 files changed, 18 insertions(+), 19 deletions(-) delete mode 100644 client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 create mode 100644 client/sniffer/licenses/jackson-core-2.9.2.jar.sha1 delete mode 100644 core/licenses/jackson-core-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-core-2.9.2.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-cbor-2.9.2.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-smile-2.9.2.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-yaml-2.9.2.jar.sha1 delete mode 100644 core/licenses/snakeyaml-1.15.jar.sha1 create mode 100644 core/licenses/snakeyaml-1.18.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 36bdd5ad51208..41313ffa95e48 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -5,8 +5,8 @@ lucene = 7.1.0-snapshot-f33ed4ba12a # optional dependencies spatial4j = 0.6 jts = 1.13 -jackson = 2.8.6 -snakeyaml = 1.15 +jackson = 2.9.2 +snakeyaml = 1.18 # when updating log4j, please update also docs/java-api/index.asciidoc log4j = 2.9.1 slf4j = 1.6.2 diff --git a/client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 b/client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 deleted file mode 100644 index af7677d13c28c..0000000000000 --- a/client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -2ef7b1cc34de149600f5e75bc2d5bf40de894e60 \ No newline at end of file diff --git a/client/sniffer/licenses/jackson-core-2.9.2.jar.sha1 b/client/sniffer/licenses/jackson-core-2.9.2.jar.sha1 new file mode 100644 index 0000000000000..cc47c1926ac96 --- /dev/null +++ b/client/sniffer/licenses/jackson-core-2.9.2.jar.sha1 @@ -0,0 +1 @@ +aed20e50152a2f19adc1995c8d8f307c7efa414d \ No newline at end of file diff --git a/core/licenses/jackson-core-2.8.6.jar.sha1 b/core/licenses/jackson-core-2.8.6.jar.sha1 deleted file mode 100644 index af7677d13c28c..0000000000000 --- a/core/licenses/jackson-core-2.8.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -2ef7b1cc34de149600f5e75bc2d5bf40de894e60 \ No newline at end of file diff --git a/core/licenses/jackson-core-2.9.2.jar.sha1 b/core/licenses/jackson-core-2.9.2.jar.sha1 new file mode 100644 index 0000000000000..cc47c1926ac96 --- /dev/null +++ b/core/licenses/jackson-core-2.9.2.jar.sha1 @@ -0,0 +1 @@ +aed20e50152a2f19adc1995c8d8f307c7efa414d \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 b/core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 deleted file mode 100644 index 6a2e980235381..0000000000000 --- a/core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -b88721371cfa2d7242bb5e52fe70861aa061c050 \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-cbor-2.9.2.jar.sha1 b/core/licenses/jackson-dataformat-cbor-2.9.2.jar.sha1 new file mode 100644 index 0000000000000..6ea3f9e75f854 --- /dev/null +++ b/core/licenses/jackson-dataformat-cbor-2.9.2.jar.sha1 @@ -0,0 +1 @@ +9ad705ca14f5d1879dfffc3d94a521bf2f2e8ea7 \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 b/core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 deleted file mode 100644 index 19be9a2040bed..0000000000000 --- a/core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -71590ad45cee21249774e2f93e5eca66e446cef3 \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-smile-2.9.2.jar.sha1 b/core/licenses/jackson-dataformat-smile-2.9.2.jar.sha1 new file mode 100644 index 0000000000000..9abd2beeb2d63 --- /dev/null +++ b/core/licenses/jackson-dataformat-smile-2.9.2.jar.sha1 @@ -0,0 +1 @@ +a7cf50aff5bd96e3a0ba551a688bf402e2a594c3 \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 b/core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 deleted file mode 100644 index c61dad3bbcdd7..0000000000000 --- a/core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8bd44d50f9a6cdff9c7578ea39d524eb519e35ab \ No newline at end of file diff --git a/core/licenses/jackson-dataformat-yaml-2.9.2.jar.sha1 b/core/licenses/jackson-dataformat-yaml-2.9.2.jar.sha1 new file mode 100644 index 0000000000000..f4a417d4ad0b9 --- /dev/null +++ b/core/licenses/jackson-dataformat-yaml-2.9.2.jar.sha1 @@ -0,0 +1 @@ +cafb9bafb3fc94ac18ed53043396f2c7bccd6c4f \ No newline at end of file diff --git a/core/licenses/snakeyaml-1.15.jar.sha1 b/core/licenses/snakeyaml-1.15.jar.sha1 deleted file mode 100644 index 48391d6d9e1a7..0000000000000 --- a/core/licenses/snakeyaml-1.15.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3b132bea69e8ee099f416044970997bde80f4ea6 \ No newline at end of file diff --git a/core/licenses/snakeyaml-1.18.jar.sha1 b/core/licenses/snakeyaml-1.18.jar.sha1 new file mode 100644 index 0000000000000..53942552cf724 --- /dev/null +++ b/core/licenses/snakeyaml-1.18.jar.sha1 @@ -0,0 +1 @@ +e4a441249ade301985cb8d009d4e4a72b85bf68e \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java b/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java index 17398b7139b67..4d0a9f6919cbb 100644 --- a/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java +++ b/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java @@ -24,9 +24,6 @@ /** * A character stream whose source is a string that is not thread safe - *

- * (shay.banon - * ) */ public class FastStringReader extends Reader implements CharSequence { @@ -34,6 +31,7 @@ public class FastStringReader extends Reader implements CharSequence { private int length; private int next = 0; private int mark = 0; + private boolean closed = false; /** * Creates a new string reader. @@ -49,8 +47,9 @@ public FastStringReader(String s) { * Check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { - if (length == -1) + if (closed) { throw new IOException("Stream closed"); + } } @Override @@ -196,7 +195,7 @@ public void reset() throws IOException { */ @Override public void close() { - length = -1; + closed = true; } @Override diff --git a/core/src/test/java/org/elasticsearch/rest/action/RestActionsTests.java b/core/src/test/java/org/elasticsearch/rest/action/RestActionsTests.java index 401cc79b02092..629145e474f0d 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/RestActionsTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/RestActionsTests.java @@ -72,18 +72,18 @@ public void testParseTopLevelBuilderEmptyObject() throws IOException { public void testParseTopLevelBuilderMalformedJson() throws IOException { for (String requestBody : Arrays.asList("\"\"", "\"someString\"", "\"{\"")) { try (XContentParser parser = createParser(JsonXContent.jsonXContent, requestBody)) { - ParsingException exception = - expectThrows(ParsingException.class, () -> RestActions.getQueryContent(parser)); + ParsingException exception = expectThrows(ParsingException.class, () -> RestActions.getQueryContent(parser)); assertEquals("Expected [START_OBJECT] but found [VALUE_STRING]", exception.getMessage()); } } } public void testParseTopLevelBuilderIncompleteJson() throws IOException { - for (String requestBody : Arrays.asList("{", "{ \"query\" :")) { + final String incomplete = "{\"query\":"; + for (int i = 1; i <= incomplete.length(); i++) { + String requestBody = incomplete.substring(0, i); try (XContentParser parser = createParser(JsonXContent.jsonXContent, requestBody)) { - ParsingException exception = - expectThrows(ParsingException.class, () -> RestActions.getQueryContent(parser)); + ParsingException exception = expectThrows(ParsingException.class, () -> RestActions.getQueryContent(parser)); assertEquals("Failed to parse", exception.getMessage()); assertEquals(JsonEOFException.class, exception.getRootCause().getClass()); } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java index 66ffb87e8da14..5496edd415be6 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/JsonProcessorTests.java @@ -62,7 +62,7 @@ public void testInvalidJson() { Exception exception = expectThrows(IllegalArgumentException.class, () -> jsonProcessor.execute(ingestDocument)); assertThat(exception.getCause().getCause().getMessage(), equalTo("Unrecognized token" + " 'invalid': was expecting ('true', 'false' or 'null')\n" - + " at [Source: invalid json; line: 1, column: 8]")); + + " at [Source: (org.elasticsearch.common.io.FastStringReader)\"invalid json\"; line: 1, column: 8]")); } public void testFieldMissing() {