diff --git a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java index 4ed6e2be9..613dec493 100644 --- a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java +++ b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java @@ -843,6 +843,7 @@ protected JsonToken _handleTaggedBinary(int tag) throws IOException } _numberBigInt = nr; _numTypesValid = NR_BIGINT; + _tagValue = -1; return (_currToken = JsonToken.VALUE_NUMBER_INT); } diff --git a/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/GeneratorSimpleTest.java b/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/GeneratorSimpleTest.java index e5bc2e56b..017f5b377 100644 --- a/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/GeneratorSimpleTest.java +++ b/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/GeneratorSimpleTest.java @@ -2,6 +2,7 @@ import java.io.*; import java.math.BigDecimal; +import java.math.BigInteger; import java.util.*; import org.junit.Assert; @@ -398,7 +399,7 @@ public void testCopyCurrentEventWithTag() throws Exception { targetBytes.toByteArray()); } - public void testCopyCurrentSturctureWithTag() throws Exception { + public void testCopyCurrentStructureWithTaggedArray() throws Exception { final ByteArrayOutputStream sourceBytes = new ByteArrayOutputStream(); final CBORGenerator sourceGen = cborGenerator(sourceBytes); sourceGen.writeNumber(BigDecimal.ONE); @@ -422,4 +423,24 @@ public void testCopyCurrentSturctureWithTag() throws Exception { }, targetBytes.toByteArray()); } + + + public void testCopyCurrentStructureWithTaggedBinary() throws Exception { + final ByteArrayOutputStream sourceBytes = new ByteArrayOutputStream(); + final CBORGenerator sourceGen = cborGenerator(sourceBytes); + sourceGen.writeNumber(BigInteger.ZERO); + sourceGen.close(); + + final ByteArrayOutputStream targetBytes = new ByteArrayOutputStream(); + final CBORGenerator gen = cborGenerator(targetBytes); + final CBORParser cborParser = cborParser(sourceBytes); + cborParser.nextToken(); + gen.copyCurrentStructure(cborParser); + gen.close(); + cborParser.close(); + + Assert.assertArrayEquals( + sourceBytes.toByteArray(), + targetBytes.toByteArray()); + } }