Skip to content

Commit

Permalink
Merge branch '2.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 6, 2019
2 parents a45ba18 + ff60fb0 commit a8fbb07
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,8 @@ Henrik Gustafsson (gsson@github)
Philippe Marschall (marschall@github)
* Requested #480: `SerializableString` value can not directly render to Writer
(2.10.0)
David Nault (dnault@github)
* Reported #531: Non-blocking parser reports incorrect locations when fed with
non-zero offset
(2.10.0)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ JSON library.

#516: _inputPtr off-by-one in UTF8StreamJsonParser._parseNumber2()
(reported by Henrik G)
#531: Non-blocking parser reports incorrect locations when fed with non-zero offset
(reported by David N)

2.9.8 (15-Dec-2018)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void feedInput(byte[] buf, int start, int end) throws IOException
_currInputRowStart = start - (_inputEnd - _currInputRowStart);

// And then update buffer settings
_currBufferStart = start;
_inputBuffer = buf;
_inputPtr = start;
_inputEnd = end;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.fasterxml.jackson.core.json.async;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.async.AsyncTestBase;
import com.fasterxml.jackson.core.async.ByteArrayFeeder;
import com.fasterxml.jackson.core.json.JsonFactory;

public class AsyncLocationTest extends AsyncTestBase
{
private final JsonFactory DEFAULT_F = new JsonFactory();

// for [core#531]
public void testLocationOffsets() throws Exception
{
JsonParser parser = DEFAULT_F.createNonBlockingByteArrayParser(ObjectReadContext.empty());
ByteArrayFeeder feeder = (ByteArrayFeeder) parser.getNonBlockingInputFeeder();

byte[] input = utf8Bytes("[[[");

feeder.feedInput(input, 2, 3);
assertEquals(JsonToken.START_ARRAY, parser.nextToken());
assertEquals(1, parser.getCurrentLocation().getByteOffset());
assertEquals(1, parser.getTokenLocation().getByteOffset());
assertEquals(1, parser.getCurrentLocation().getLineNr());
assertEquals(1, parser.getTokenLocation().getLineNr());
assertEquals(2, parser.getCurrentLocation().getColumnNr());
assertEquals(1, parser.getTokenLocation().getColumnNr());

feeder.feedInput(input, 0, 1);
assertEquals(JsonToken.START_ARRAY, parser.nextToken());
assertEquals(2, parser.getCurrentLocation().getByteOffset());
assertEquals(2, parser.getTokenLocation().getByteOffset());
assertEquals(1, parser.getCurrentLocation().getLineNr());
assertEquals(1, parser.getTokenLocation().getLineNr());
assertEquals(3, parser.getCurrentLocation().getColumnNr());
assertEquals(2, parser.getTokenLocation().getColumnNr());
parser.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.JsonParser.NumberType;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.exc.InputCoercionException;

public class NumberCoercionTest extends BaseTest
Expand Down

0 comments on commit a8fbb07

Please sign in to comment.