From 894787bc6590001251ad9b054146016345a7f1a1 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Tue, 31 Oct 2017 15:07:14 +0100 Subject: [PATCH] Upgrade to Jackson 2.8.10 --- buildSrc/version.properties | 4 +- .../licenses/jackson-core-2.8.10.jar.sha1 | 1 + .../licenses/jackson-core-2.8.6.jar.sha1 | 1 - core/licenses/jackson-core-2.8.10.jar.sha1 | 1 + core/licenses/jackson-core-2.8.6.jar.sha1 | 1 - .../jackson-dataformat-cbor-2.8.10.jar.sha1 | 1 + .../jackson-dataformat-cbor-2.8.6.jar.sha1 | 1 - .../jackson-dataformat-smile-2.8.10.jar.sha1 | 1 + .../jackson-dataformat-smile-2.8.6.jar.sha1 | 1 - .../jackson-dataformat-yaml-2.8.10.jar.sha1 | 1 + .../jackson-dataformat-yaml-2.8.6.jar.sha1 | 1 - core/licenses/snakeyaml-1.15.jar.sha1 | 1 - core/licenses/snakeyaml-1.17.jar.sha1 | 1 + .../common/io/FastStringReader.java | 6 ++- .../common/xcontent/XContentParserTests.java | 42 +++++++++++++++++++ .../org/elasticsearch/test/RandomObjects.java | 2 +- 16 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 client/sniffer/licenses/jackson-core-2.8.10.jar.sha1 delete mode 100644 client/sniffer/licenses/jackson-core-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-core-2.8.10.jar.sha1 delete mode 100644 core/licenses/jackson-core-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-cbor-2.8.10.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-smile-2.8.10.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1 create mode 100644 core/licenses/jackson-dataformat-yaml-2.8.10.jar.sha1 delete mode 100644 core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1 delete mode 100644 core/licenses/snakeyaml-1.15.jar.sha1 create mode 100644 core/licenses/snakeyaml-1.17.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 7e34dec9e4bf8..066fd1d4693b7 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.8.10 +snakeyaml = 1.17 # 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.10.jar.sha1 b/client/sniffer/licenses/jackson-core-2.8.10.jar.sha1 new file mode 100644 index 0000000000000..a322d371e265e --- /dev/null +++ b/client/sniffer/licenses/jackson-core-2.8.10.jar.sha1 @@ -0,0 +1 @@ +eb21a035c66ad307e66ec8fce37f5d50fd62d039 \ No newline at end of file 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/core/licenses/jackson-core-2.8.10.jar.sha1 b/core/licenses/jackson-core-2.8.10.jar.sha1 new file mode 100644 index 0000000000000..a322d371e265e --- /dev/null +++ b/core/licenses/jackson-core-2.8.10.jar.sha1 @@ -0,0 +1 @@ +eb21a035c66ad307e66ec8fce37f5d50fd62d039 \ 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-dataformat-cbor-2.8.10.jar.sha1 b/core/licenses/jackson-dataformat-cbor-2.8.10.jar.sha1 new file mode 100644 index 0000000000000..1d3e18e21a694 --- /dev/null +++ b/core/licenses/jackson-dataformat-cbor-2.8.10.jar.sha1 @@ -0,0 +1 @@ +1c58cc9313ddf19f0900cd61ed044874278ce320 \ 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-smile-2.8.10.jar.sha1 b/core/licenses/jackson-dataformat-smile-2.8.10.jar.sha1 new file mode 100644 index 0000000000000..4f4cacde22079 --- /dev/null +++ b/core/licenses/jackson-dataformat-smile-2.8.10.jar.sha1 @@ -0,0 +1 @@ +e853081fadaad3e98ed801937acc3d8f77580686 \ 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-yaml-2.8.10.jar.sha1 b/core/licenses/jackson-dataformat-yaml-2.8.10.jar.sha1 new file mode 100644 index 0000000000000..40bcb05f69795 --- /dev/null +++ b/core/licenses/jackson-dataformat-yaml-2.8.10.jar.sha1 @@ -0,0 +1 @@ +1e08caf1d787c825307d8cc6362452086020d853 \ 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/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.17.jar.sha1 b/core/licenses/snakeyaml-1.17.jar.sha1 new file mode 100644 index 0000000000000..9ac6e87f2244a --- /dev/null +++ b/core/licenses/snakeyaml-1.17.jar.sha1 @@ -0,0 +1 @@ +7a27ea250c5130b2922b86dea63cbb1cc10a660c \ 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..2ac7e9022e687 100644 --- a/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java +++ b/core/src/main/java/org/elasticsearch/common/io/FastStringReader.java @@ -34,6 +34,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 +50,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 +198,7 @@ public void reset() throws IOException { */ @Override public void close() { - length = -1; + closed = true; } @Override diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java index 3397a463ea823..8e3246d8b8a59 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/XContentParserTests.java @@ -42,6 +42,48 @@ public class XContentParserTests extends ESTestCase { + public void testFloat() throws IOException { + final XContentType xContentType = randomFrom(XContentType.values()); + + final String field = randomAlphaOfLengthBetween(1, 5); + final Float value = randomFloat(); + + try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) { + builder.startObject(); + if (randomBoolean()) { + builder.field(field, value); + } else { + builder.field(field).value(value); + } + builder.endObject(); + + final Number number; + try (XContentParser parser = createParser(xContentType.xContent(), builder.bytes())) { + assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken()); + assertEquals(XContentParser.Token.FIELD_NAME, parser.nextToken()); + assertEquals(field, parser.currentName()); + assertEquals(XContentParser.Token.VALUE_NUMBER, parser.nextToken()); + + number = parser.numberValue(); + + assertEquals(XContentParser.Token.END_OBJECT, parser.nextToken()); + assertNull(parser.nextToken()); + } + + assertEquals(value, number.floatValue(), 0.0f); + + if (xContentType == XContentType.CBOR) { + // CBOR parses back a float + assertTrue(number instanceof Float); + } else { + // JSON, YAML and SMILE parses back the float value as a double + // This will change for SMILE in Jackson 2.9 where all binary based + // formats will return a float + assertTrue(number instanceof Double); + } + } + } + public void testReadList() throws IOException { assertThat(readList("{\"foo\": [\"bar\"]}"), contains("bar")); assertThat(readList("{\"foo\": [\"bar\",\"baz\"]}"), contains("bar", "baz")); diff --git a/test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java b/test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java index 67999b82a2fe6..1868fc34a991f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java +++ b/test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java @@ -108,7 +108,7 @@ public static Tuple, List> randomStoredFieldValues(Random r //with CBOR we get back a float expectedParsedValues.add(randomFloat); } else if (xContentType == XContentType.SMILE) { - //with SMILE we get back a double + //with SMILE we get back a double (this will change in Jackson 2.9 where it will return a Float) expectedParsedValues.add(randomFloat.doubleValue()); } else { //with JSON AND YAML we get back a double, but with float precision.