Skip to content

Commit 6bf8509

Browse files
committed
Complete error reporting improvements (mostly for #240)
1 parent ab4f329 commit 6bf8509

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,9 @@ public String nextFieldName() throws IOException
12011201
// inlined "_decodeFieldName()"
12021202

12031203
if (_inputPtr >= _inputEnd) {
1204-
loadMoreGuaranteed();
1204+
if (!loadMore()) {
1205+
_eofAsNextToken();
1206+
}
12051207
}
12061208
final int ch = _inputBuffer[_inputPtr++];
12071209
final int type = ((ch >> 5) & 0x7);
@@ -2560,7 +2562,11 @@ protected byte[] _finishLongContiguousBytes(final int expLen) throws IOException
25602562
protected final JsonToken _decodePropertyName() throws IOException
25612563
{
25622564
if (_inputPtr >= _inputEnd) {
2563-
loadMoreGuaranteed();
2565+
// 30-Jan-2021, tatu: To get more specific exception, won't use
2566+
// "loadMoreGuaranteed()" but instead:
2567+
if (!loadMore()) {
2568+
_eofAsNextToken();
2569+
}
25642570
}
25652571
final int ch = _inputBuffer[_inputPtr++];
25662572
final int type = ((ch >> 5) & 0x7);

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseIncompleteArray240Test.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public void testIncompleteMarkerBasedArray() throws Exception
4040
}
4141

4242
// And might as well do the same for Objects too
43-
/*
4443
public void testIncompleteFixedSizeObject() throws Exception
4544
{
4645
final byte[] input = { (byte) 0xA3 };
@@ -50,7 +49,6 @@ public void testIncompleteFixedSizeObject() throws Exception
5049
p.nextToken();
5150
fail("Should NOT pass");
5251
} catch (StreamReadException e) {
53-
e.printStackTrace();
5452
verifyException(e, "Unexpected end-of-input in Object value: expected 3 more");
5553
}
5654
}
@@ -65,9 +63,9 @@ public void testIncompleteMarkerBasedObject() throws Exception
6563
p.nextToken();
6664
fail("Should NOT pass");
6765
} catch (StreamReadException e) {
68-
verifyException(e, "Unexpected end-of-input in Object value: expected an element or ");
66+
verifyException(e,
67+
"Unexpected end-of-input in Object value: expected a property or close marker");
6968
}
7069
}
7170
}
72-
*/
7371
}

0 commit comments

Comments
 (0)