[Git][java-team/jackson-core][upstream] 2 commits: New upstream version 2.10.2

Mechtilde Stehmann gitlab at salsa.debian.org
Sun Mar 8 11:22:19 GMT 2020



Mechtilde Stehmann pushed to branch upstream at Debian Java Maintainers / jackson-core


Commits:
3cce7a0e by Mechtilde at 2020-01-12T14:00:47+01:00
New upstream version 2.10.2
- - - - -
6ded601c by Mechtilde at 2020-03-08T11:17:13+01:00
New upstream version 2.10.3
- - - - -


17 changed files:

- .travis.yml
- pom.xml
- release-notes/CREDITS-2.x
- release-notes/VERSION-2.x
- src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java
- src/main/java/com/fasterxml/jackson/core/format/DataFormatMatcher.java
- src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java
- src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java
- src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java
- src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java
- src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
- src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java
- src/test/java/com/fasterxml/jackson/core/filter/JsonPointerGeneratorFilteringTest.java
- src/test/java/com/fasterxml/jackson/core/format/DataFormatMatcherTest.java
- src/test/java/com/fasterxml/jackson/core/format/TestJsonFormatDetection.java
- src/test/java/com/fasterxml/jackson/core/read/LocationOffsetsTest.java
- src/test/java/com/fasterxml/jackson/core/read/UTF8NamesParseTest.java


Changes:

=====================================
.travis.yml
=====================================
@@ -5,7 +5,8 @@ language: java
   - oraclejdk11
 
 # Below this line is configuration for deploying to the Sonatype OSS repo
-# http://blog.xeiam.com/2013/05/configure-travis-ci-to-deploy-snapshots.html
+#   https://knowm.org/configure-travis-ci-to-deploy-snapshots/
+
 before_install: "git clone -b travis `git config --get remote.origin.url` target/travis"
 after_success: "mvn deploy --settings target/travis/settings.xml"
 
@@ -15,12 +16,6 @@ branches:
     - master
     - "2.10"
 
-# to make jdk6 work, as per: https://github.com/travis-ci/travis-ci/issues/8199
-addons:
-  apt:
-    packages:
-      - openjdk-6-jdk
-
 env:
   global:
     - secure: "YW0hrdsHvH41pb5uPJ2DGzXrBgOVT7nEyag/bAQoDcSlOQ/g55tnY6rIGkqE/aYD47IroTEhW4yLyM3tZpbrqwagX4dUX90ukjcUwUvFE1ePTSEfdBtuHVwl8f6HmLIIw2yK0dQ1gOJ21T+3g+wddvK+6sWBJJ+s3O1FePDh6X0="


=====================================
pom.xml
=====================================
@@ -3,13 +3,13 @@
   <parent>
     <groupId>com.fasterxml.jackson</groupId>
     <artifactId>jackson-base</artifactId>
-    <version>2.10.1</version>
+    <version>2.10.3</version>
   </parent>
 
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-core</artifactId>
   <name>Jackson-core</name>
-  <version>2.10.1</version>
+  <version>2.10.3</version>
   <packaging>bundle</packaging>
   <description>Core Jackson processing abstractions (aka Streaming API), implementation for JSON</description>
   <inceptionYear>2008</inceptionYear>
@@ -19,7 +19,7 @@
     <connection>scm:git:git at github.com:FasterXML/jackson-core.git</connection>
     <developerConnection>scm:git:git at github.com:FasterXML/jackson-core.git</developerConnection>
     <url>http://github.com/FasterXML/jackson-core</url>    
-    <tag>jackson-core-2.10.1</tag>
+    <tag>jackson-core-2.10.3</tag>
   </scm>
 
   <properties>


=====================================
release-notes/CREDITS-2.x
=====================================
@@ -115,6 +115,9 @@ Alessio Soldano (asoldano at github)
 Arnaud Roger (arnaudroger at github)
   * Contributed #359: FilteringGeneratorDelegate does not override writeStartObject(Object forValue)
    (2.8.8)
+  * Reported, contributed fix for #580: FilteringGeneratorDelegate writeRawValue delegate
+   to `writeRaw()` instead of `writeRawValue()`
+   (2.10.2)
 
 
 Emily Selwood (emilyselwood at github)
@@ -193,10 +196,18 @@ David Nault (dnault at github)
   (2.10.0)
 
 Fabien Renaud (fabienrenaud at github)
-  * Reported, contributed fix fir #533: UTF-8 BOM not accounted for in
+  * Reported, contributed fix for #533: UTF-8 BOM not accounted for in
     `JsonLocation.getByteOffset()`
   (2.10.0)
+  * Reported, contributed fix for #603: 'JsonParser.getCurrentLocation()`
+    byte/char offset update incorrectly for big payloads
+  (2.10.3)
 
 Todd O'Bryan (toddobryan at github)
   * Contributed fix fox #455: Jackson reports wrong locations for JsonEOFException
   (2.10.1)
+
+Scott Leberknight (sleberknight at github)
+  * Reported, contributed fix for #592: DataFormatMatcher#getMatchedFormatName throws NPE
+    when no match exists
+  (2.10.3)


=====================================
release-notes/VERSION-2.x
=====================================
@@ -14,6 +14,21 @@ JSON library.
 === Releases ===
 ------------------------------------------------------------------------
 
+2.10.3 (03-Mar-2020)
+
+#592: DataFormatMatcher#getMatchedFormatName throws NPE when no match exists
+ (reported by Scott L)
+#603: 'JsonParser.getCurrentLocation()` byte/char offset update incorrectly for big payloads
+ (reported, fix contributed by Fabien R)
+
+2.10.2 (05-Jan-2020)
+
+#580: FilteringGeneratorDelegate writeRawValue delegate to `writeRaw()`
+  instead of `writeRawValue()`
+ (reported by Arnaud R)
+#582: `FilteringGeneratorDelegate` bug when filtering arrays (in 2.10.1)
+ (reported by alarribeau at github)
+
 2.10.1 (09-Nov-2019)
 
 #455: Jackson reports wrong locations for JsonEOFException


=====================================
src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java
=====================================
@@ -173,7 +173,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
             _filterContext = _filterContext.createChildArrayContext(_itemFilter, false);
         }
     }
-        
+
     @Override
     public void writeStartArray(int size) throws IOException
     {
@@ -202,6 +202,64 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
             _filterContext = _filterContext.createChildArrayContext(_itemFilter, false);
         }
     }
+
+    @Override
+    public void writeStartArray(Object forValue) throws IOException
+    {
+        if (_itemFilter == null) {
+            _filterContext = _filterContext.createChildArrayContext(null, false);
+            return;
+        }
+        if (_itemFilter == TokenFilter.INCLUDE_ALL) {
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, true);
+            delegate.writeStartArray(forValue);
+            return;
+        }
+        _itemFilter = _filterContext.checkValue(_itemFilter);
+        if (_itemFilter == null) {
+            _filterContext = _filterContext.createChildArrayContext(null, false);
+            return;
+        }
+        if (_itemFilter != TokenFilter.INCLUDE_ALL) {
+            _itemFilter = _itemFilter.filterStartArray();
+        }
+        if (_itemFilter == TokenFilter.INCLUDE_ALL) {
+            _checkParentPath();
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, true);
+            delegate.writeStartArray(forValue);
+        } else {
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, false);
+        }
+    }
+
+    @Override
+    public void writeStartArray(Object forValue, int size) throws IOException
+    {
+        if (_itemFilter == null) {
+            _filterContext = _filterContext.createChildArrayContext(null, false);
+            return;
+        }
+        if (_itemFilter == TokenFilter.INCLUDE_ALL) {
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, true);
+            delegate.writeStartArray(forValue, size);
+            return;
+        }
+        _itemFilter = _filterContext.checkValue(_itemFilter);
+        if (_itemFilter == null) {
+            _filterContext = _filterContext.createChildArrayContext(null, false);
+            return;
+        }
+        if (_itemFilter != TokenFilter.INCLUDE_ALL) {
+            _itemFilter = _itemFilter.filterStartArray();
+        }
+        if (_itemFilter == TokenFilter.INCLUDE_ALL) {
+            _checkParentPath();
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, true);
+            delegate.writeStartArray(forValue, size);
+        } else {
+            _filterContext = _filterContext.createChildArrayContext(_itemFilter, false);
+        }
+    }
     
     @Override
     public void writeEndArray() throws IOException
@@ -242,7 +300,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
             _filterContext = _filterContext.createChildObjectContext(f, false);
         }
     }
-    
+
     @Override
     public void writeStartObject(Object forValue) throws IOException
     {
@@ -273,6 +331,36 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
         }
     }
 
+    @Override
+    public void writeStartObject(Object forValue, int size) throws IOException
+    {
+        if (_itemFilter == null) {
+            _filterContext = _filterContext.createChildObjectContext(_itemFilter, false);
+            return;
+        }
+        if (_itemFilter == TokenFilter.INCLUDE_ALL) {
+            _filterContext = _filterContext.createChildObjectContext(_itemFilter, true);
+            delegate.writeStartObject(forValue, size);
+            return;
+        }
+
+        TokenFilter f = _filterContext.checkValue(_itemFilter);
+        if (f == null) {
+            return;
+        }
+
+        if (f != TokenFilter.INCLUDE_ALL) {
+            f = f.filterStartObject();
+        }
+        if (f == TokenFilter.INCLUDE_ALL) {
+            _checkParentPath();
+            _filterContext = _filterContext.createChildObjectContext(f, true);
+            delegate.writeStartObject(forValue, size);
+        } else {
+            _filterContext = _filterContext.createChildObjectContext(f, false);
+        }
+    }
+
     @Override
     public void writeEndObject() throws IOException
     {
@@ -322,6 +410,12 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
         }
     }
 
+    // 02-Dec-2019, tatu: Not sure what else to do... so use default impl from base class
+    @Override
+    public void writeFieldId(long id) throws IOException {
+        writeFieldName(Long.toString(id));
+    }
+
     /*
     /**********************************************************
     /* Public API, write methods, text/String values
@@ -427,7 +521,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
     public void writeRaw(String text, int offset, int len) throws IOException
     {
         if (_checkRawValueWrite()) {
-            delegate.writeRaw(text);
+            delegate.writeRaw(text, offset, len);
         }
     }
 
@@ -459,7 +553,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
     public void writeRawValue(String text) throws IOException
     {
         if (_checkRawValueWrite()) {
-            delegate.writeRaw(text);
+            delegate.writeRawValue(text);
         }
     }
 
@@ -467,7 +561,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
     public void writeRawValue(String text, int offset, int len) throws IOException
     {
         if (_checkRawValueWrite()) {
-            delegate.writeRaw(text, offset, len);
+            delegate.writeRawValue(text, offset, len);
         }
     }
 
@@ -475,7 +569,7 @@ public class FilteringGeneratorDelegate extends JsonGeneratorDelegate
     public void writeRawValue(char[] text, int offset, int len) throws IOException
     {
         if (_checkRawValueWrite()) {
-            delegate.writeRaw(text, offset, len);
+            delegate.writeRawValue(text, offset, len);
         }
     }
 


=====================================
src/main/java/com/fasterxml/jackson/core/format/DataFormatMatcher.java
=====================================
@@ -91,7 +91,7 @@ public class DataFormatMatcher
      *</pre>
      */
     public String getMatchedFormatName() {
-        return _match.getFormatName();
+        return hasMatch() ? getMatch().getFormatName() : null;
     }
     
     /*


=====================================
src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java
=====================================
@@ -244,14 +244,10 @@ public class ReaderBasedJsonParser // final in 2.3, earlier
     
     protected boolean _loadMore() throws IOException
     {
-        final int bufSize = _inputEnd;
-
         if (_reader != null) {
             int count = _reader.read(_inputBuffer, 0, _inputBuffer.length);
             if (count > 0) {
-                _inputPtr = 0;
-                _inputEnd = count;
-
+                final int bufSize = _inputEnd;
                 _currInputProcessed += bufSize;
                 _currInputRowStart -= bufSize;
 
@@ -260,6 +256,9 @@ public class ReaderBasedJsonParser // final in 2.3, earlier
                 //   in negative value, which is fine as combine value remains unchanged.
                 _nameStartOffset -= bufSize;
 
+                _inputPtr = 0;
+                _inputEnd = count;
+
                 return true;
             }
             // End of input


=====================================
src/main/java/com/fasterxml/jackson/core/json/UTF8DataInputJsonParser.java
=====================================
@@ -1928,12 +1928,12 @@ public class UTF8DataInputJsonParser
             case 4: // 4-byte UTF
                 c = _decodeUtf8_4(c);
                 // Let's add first part right away:
-                outBuf[outPtr++] = (char) (0xD800 | (c >> 10));
                 if (outPtr >= outBuf.length) {
                     outBuf = _textBuffer.finishCurrentSegment();
                     outPtr = 0;
                     outEnd = outBuf.length;
                 }
+                outBuf[outPtr++] = (char) (0xD800 | (c >> 10));
                 c = 0xDC00 | (c & 0x3FF);
                 // And let the other char output down below
                 break;


=====================================
src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java
=====================================
@@ -1720,11 +1720,11 @@ public class UTF8JsonGenerator
         return (outputPtr + len);
     }
     
-    private final int _handleLongCustomEscape(byte[] outputBuffer, int outputPtr, int outputEnd, byte[] raw,
-            int remainingChars)
+    private final int _handleLongCustomEscape(byte[] outputBuffer, int outputPtr, int outputEnd,
+            byte[] raw, int remainingChars)
         throws IOException, JsonGenerationException
     {
-        int len = raw.length;
+        final int len = raw.length;
         if ((outputPtr + len) > outputEnd) {
             _outputTail = outputPtr;
             _flushBuffer();
@@ -1733,11 +1733,12 @@ public class UTF8JsonGenerator
                 _outputStream.write(raw, 0, len);
                 return outputPtr;
             }
-            System.arraycopy(raw, 0, outputBuffer, outputPtr, len);
-            outputPtr += len;
         }
+        System.arraycopy(raw, 0, outputBuffer, outputPtr, len);
+        outputPtr += len;
         // but is the invariant still obeyed? If not, flush once more
         if ((outputPtr +  6 * remainingChars) > outputEnd) {
+            _outputTail = outputPtr;
             _flushBuffer();
             return _outputTail;
         }


=====================================
src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java
=====================================
@@ -210,7 +210,6 @@ public class UTF8StreamJsonParser
 
     protected final boolean _loadMore() throws IOException
     {
-        final int bufSize = _inputEnd;
         if (_inputStream != null) {
             int space = _inputBuffer.length;
             if (space == 0) { // only occurs when we've been closed
@@ -219,17 +218,19 @@ public class UTF8StreamJsonParser
             
             int count = _inputStream.read(_inputBuffer, 0, space);
             if (count > 0) {
-                _inputPtr = 0;
-                _inputEnd = count;
+                final int bufSize = _inputEnd;
 
-                _currInputProcessed += _inputEnd;
-                _currInputRowStart -= _inputEnd;
+                _currInputProcessed += bufSize;
+                _currInputRowStart -= bufSize;
 
                 // 26-Nov-2015, tatu: Since name-offset requires it too, must offset
                 //   this increase to avoid "moving" name-offset, resulting most likely
                 //   in negative value, which is fine as combine value remains unchanged.
                 _nameStartOffset -= bufSize;
 
+                _inputPtr = 0;
+                _inputEnd = count;
+
                 return true;
             }
             // End of input


=====================================
src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
=====================================
@@ -100,7 +100,10 @@ public class JsonGeneratorDelegate extends JsonGenerator
     
     @Override
     public boolean canOmitFields() { return delegate.canOmitFields(); }
-    
+
+    @Override
+    public boolean canWriteFormattedNumbers() { return delegate.canWriteFormattedNumbers(); }
+
     /*
     /**********************************************************
     /* Public API, configuration


=====================================
src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java
=====================================
@@ -337,4 +337,23 @@ public class BasicGeneratorFilteringTest extends BaseTest
         gen.close();
         assertEquals(aposToQuotes("{'field1':{},'field2':'val2'}"), w.toString());
     }
+
+    // [core#580]
+    public void testRawValueDelegation() throws Exception
+    {
+        StringWriter w = new StringWriter();
+        FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(JSON_F.createGenerator(w),
+                TokenFilter.INCLUDE_ALL, true, true);
+
+        gen.writeStartArray();
+        gen.writeRawValue(new char[] { '1'}, 0, 1);
+        gen.writeRawValue("123", 2, 1);
+        gen.writeRaw(',');
+        gen.writeRaw("/* comment */");
+        gen.writeRaw(" ,42", 1, 3);
+        gen.writeEndArray();
+
+        gen.close();
+        assertEquals("[1,3,/* comment */,42]", w.toString());
+    }
 }


=====================================
src/test/java/com/fasterxml/jackson/core/filter/JsonPointerGeneratorFilteringTest.java
=====================================
@@ -108,4 +108,47 @@ public class JsonPointerGeneratorFilteringTest extends com.fasterxml.jackson.cor
 
         assertEquals(aposToQuotes(exp), w.toString());
     }
+
+
+    // for [core#582]: regression wrt array filtering
+
+    public void testArrayFiltering582WithoutObject() throws IOException {
+        _testArrayFiltering582(0);
+    }
+
+    public void testArrayFiltering582WithoutSize() throws IOException {
+        _testArrayFiltering582(1);
+    }
+
+    public void testArrayFiltering582WithSize() throws IOException {
+        _testArrayFiltering582(2);
+    }
+
+    private void _testArrayFiltering582(int mode) throws IOException
+    {
+         StringWriter output = new StringWriter();
+         JsonGenerator jg = JSON_F.createGenerator(output);
+
+         FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(jg,
+                 new JsonPointerBasedFilter("/noMatch"), true, true);
+         final String[] stuff = new String[] { "foo", "bar" };
+
+         switch (mode) {
+         case 0:
+             gen.writeStartArray();
+             break;
+         case 1:
+             gen.writeStartArray(stuff);
+             break;
+         default:
+             gen.writeStartArray(stuff, stuff.length);
+         }
+         gen.writeString(stuff[0]);
+         gen.writeString(stuff[1]);
+         gen.writeEndArray();
+         gen.close();
+         jg.close();
+
+         assertEquals("", output.toString());
+    }
 }


=====================================
src/test/java/com/fasterxml/jackson/core/format/DataFormatMatcherTest.java
=====================================
@@ -35,4 +35,24 @@ public class DataFormatMatcherTest extends com.fasterxml.jackson.core.BaseTest
         verifyException(e, "Illegal start/length");
     }
   }
+
+  public void testGetMatchedFormatNameReturnsNameWhenMatches() {
+    DataFormatMatcher dataFormatMatcher = new DataFormatMatcher(null,
+            new byte[2],
+            1,
+            0,
+            new JsonFactory(),
+            MatchStrength.SOLID_MATCH);
+    assertEquals(JsonFactory.FORMAT_NAME_JSON, dataFormatMatcher.getMatchedFormatName());
+  }
+
+  public void testGetMatchedFormatNameReturnsNullWhenNoMatch() {
+    DataFormatMatcher dataFormatMatcher = new DataFormatMatcher(null,
+            new byte[2],
+            1,
+            0,
+            null,
+            MatchStrength.NO_MATCH);
+    assertNull(dataFormatMatcher.getMatchedFormatName());
+  }
 }


=====================================
src/test/java/com/fasterxml/jackson/core/format/TestJsonFormatDetection.java
=====================================
@@ -83,6 +83,7 @@ public class TestJsonFormatDetection extends com.fasterxml.jackson.core.BaseTest
         DataFormatMatcher matcher = detector.findFormat(new ByteArrayInputStream(NON_JSON.getBytes("UTF-8")));
         // should not have match
         assertFalse(matcher.hasMatch());
+        assertNull(matcher.getMatchedFormatName());
         // and thus:
         assertEquals(MatchStrength.INCONCLUSIVE, matcher.getMatchStrength());
         // also:


=====================================
src/test/java/com/fasterxml/jackson/core/read/LocationOffsetsTest.java
=====================================
@@ -2,6 +2,9 @@ package com.fasterxml.jackson.core.read;
 
 import com.fasterxml.jackson.core.*;
 
+import java.io.IOException;
+import java.util.Random;
+
 public class LocationOffsetsTest extends com.fasterxml.jackson.core.BaseTest
 {
     final JsonFactory JSON_F = new JsonFactory();
@@ -104,6 +107,45 @@ public class LocationOffsetsTest extends com.fasterxml.jackson.core.BaseTest
         p.close();
     }
 
+    public void testWithLazyStringReadStreaming() throws Exception
+    {
+        _testWithLazyStringRead(MODE_READER);
+        _testWithLazyStringRead(MODE_INPUT_STREAM);
+    }
+
+    public void testWithLazyStringReadDataInput() throws Exception
+    {
+        // DataInput-backed reader does not track column, so can not
+        // verify much; but force finishToken() regardless
+        JsonParser p = createParser(JSON_F, MODE_DATA_INPUT, "[\"text\"]");
+        assertToken(JsonToken.START_ARRAY, p.nextToken());
+        assertToken(JsonToken.VALUE_STRING, p.nextToken());
+        assertEquals(1, p.getCurrentLocation().getLineNr());
+        p.finishToken();
+        assertEquals("text", p.getText());
+        p.close();
+    }
+
+    private void _testWithLazyStringRead(int readMode) throws Exception
+    {
+        JsonParser p = createParser(JSON_F, readMode, "[\"text\"]");
+        assertToken(JsonToken.START_ARRAY, p.nextToken());
+        assertToken(JsonToken.VALUE_STRING, p.nextToken());
+        // initially location pointing to first character
+        assertEquals(3, p.getCurrentLocation().getColumnNr());
+        p.finishToken();
+        // but will move once we force reading
+        assertEquals(8, p.getCurrentLocation().getColumnNr());
+        // and no change if we call again (but is ok to call)
+        p.finishToken();
+        assertEquals(8, p.getCurrentLocation().getColumnNr());
+
+        // also just for fun, verify content
+        assertEquals("text", p.getText());
+        assertEquals(8, p.getCurrentLocation().getColumnNr());
+        p.close();
+    }
+
     // for [core#533]
     public void testUtf8Bom() throws Exception
     {
@@ -192,4 +234,75 @@ public class LocationOffsetsTest extends com.fasterxml.jackson.core.BaseTest
         System.arraycopy(bytes, 0, arr, 3, bytes.length);
         return arr;
     }
+
+    // [core#603]
+    public void testBigPayload() throws IOException {
+        JsonLocation loc;
+        JsonParser p;
+
+        String doc = "{\"key\":\"" + generateRandomAlpha(50000) + "\"}";
+
+        p = createParserUsingStream(JSON_F, doc, "UTF-8");
+
+        assertToken(JsonToken.START_OBJECT, p.nextToken());
+        loc = p.getTokenLocation();
+        assertEquals(0, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(1, loc.getColumnNr());
+        loc = p.getCurrentLocation();
+        assertEquals(1, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(2, loc.getColumnNr());
+
+        assertToken(JsonToken.FIELD_NAME, p.nextToken());
+        loc = p.getTokenLocation();
+        assertEquals(1, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(2, loc.getColumnNr());
+        loc = p.getCurrentLocation();
+        assertEquals(8, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(9, loc.getColumnNr());
+
+        assertToken(JsonToken.VALUE_STRING, p.nextToken());
+        loc = p.getTokenLocation();
+        assertEquals(7, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(8, loc.getColumnNr());
+        loc = p.getCurrentLocation();
+        assertEquals(8, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(9, loc.getColumnNr());
+
+        p.getTextCharacters();
+        loc = p.getTokenLocation();
+        assertEquals(7, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(8, loc.getColumnNr());
+        loc = p.getCurrentLocation();
+        assertEquals(doc.length() - 1, loc.getByteOffset());
+        assertEquals(-1L, loc.getCharOffset());
+        assertEquals(1, loc.getLineNr());
+        assertEquals(doc.length(), loc.getColumnNr());
+
+        p.close();
+    }
+
+    private String generateRandomAlpha(int length) {
+        StringBuilder sb = new StringBuilder(length);
+        Random rnd = new Random(length);
+        for (int i = 0; i < length; ++i) {
+            // let's limit it not to include surrogate pairs:
+            char ch = (char) ('A' + rnd.nextInt(26));
+            sb.append(ch);
+        }
+        return sb.toString();
+    }
 }


=====================================
src/test/java/com/fasterxml/jackson/core/read/UTF8NamesParseTest.java
=====================================
@@ -157,18 +157,20 @@ public class UTF8NamesParseTest
 
     public void testUtf8StringValue() throws Exception
     {
-        _testUtf8StringValue(MODE_INPUT_STREAM);
-        _testUtf8StringValue(MODE_DATA_INPUT);
-        _testUtf8StringValue(MODE_INPUT_STREAM_THROTTLED);
+        _testUtf8StringValue(MODE_INPUT_STREAM, 2900);
+        _testUtf8StringValue(MODE_DATA_INPUT, 2900);
+        _testUtf8StringValue(MODE_INPUT_STREAM_THROTTLED, 2900);
+
+        _testUtf8StringValue(MODE_INPUT_STREAM, 5300);
+        _testUtf8StringValue(MODE_DATA_INPUT, 5300);
+        _testUtf8StringValue(MODE_INPUT_STREAM_THROTTLED, 5300);
     }
 
-    public void _testUtf8StringValue(int mode) throws Exception
+    public void _testUtf8StringValue(int mode, int len) throws Exception
     {
         Random r = new Random(13);
-        //int LEN = 72000;
-        int LEN = 720;
-        StringBuilder sb = new StringBuilder(LEN + 20);
-        while (sb.length() < LEN) {
+        StringBuilder sb = new StringBuilder(len + 20);
+        while (sb.length() < len) {
             int c;
             if (r.nextBoolean()) { // ascii
                 c = 32 + (r.nextInt() & 0x3F);
@@ -188,7 +190,7 @@ public class UTF8NamesParseTest
             sb.append((char) c);
         }
 
-        ByteArrayOutputStream bout = new ByteArrayOutputStream(LEN);
+        ByteArrayOutputStream bout = new ByteArrayOutputStream(len + (len >> 2));
         OutputStreamWriter out = new OutputStreamWriter(bout, "UTF-8");
         out.write("[\"");
         String VALUE = sb.toString();



View it on GitLab: https://salsa.debian.org/java-team/jackson-core/-/compare/63928b7d4e14ea79362d8241edaafe45d2fdc8a2...6ded601c28add6634b9b8943760ce0a7dc078940

-- 
View it on GitLab: https://salsa.debian.org/java-team/jackson-core/-/compare/63928b7d4e14ea79362d8241edaafe45d2fdc8a2...6ded601c28add6634b9b8943760ce0a7dc078940
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20200308/aa6b8ff3/attachment.html>


More information about the pkg-java-commits mailing list