Skip to content

Commit b1db8cf

Browse files
committed
TokenBuffer.copyCurrentEvent does not expect getNumberType return null.
1 parent 1bf2140 commit b1db8cf

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public NumberType getNumberType() throws IOException
245245
} else {
246246
return NumberType.INT;
247247
}
248+
case FLOAT:
249+
return NumberType.FLOAT;
248250
default:
249251
}
250252
}

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonParserTest.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
*/
1414

1515
package com.fasterxml.jackson.dataformat.ion;
16-
16+
1717
import com.fasterxml.jackson.core.JsonParser;
1818
import com.fasterxml.jackson.core.JsonToken;
1919
import com.fasterxml.jackson.core.ObjectReadContext;
20-
import com.fasterxml.jackson.dataformat.ion.IonFactory;
21-
import com.fasterxml.jackson.dataformat.ion.IonParser;
2220

2321
import org.junit.Assert;
22+
import software.amazon.ion.IonReader;
2423
import software.amazon.ion.IonSystem;
2524
import software.amazon.ion.IonValue;
2625
import software.amazon.ion.system.IonSystemBuilder;
2726

27+
import java.io.IOException;
2828
import java.math.BigInteger;
2929
import org.junit.Test;
3030

@@ -58,4 +58,23 @@ public void testGetNumberType() throws Exception {
5858
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, floatParser.nextToken());
5959
Assert.assertEquals(JsonParser.NumberType.DOUBLE, floatParser.getNumberType());
6060
}
61+
62+
@Test
63+
public void testFloatType() throws IOException
64+
{
65+
final ObjectReadContext ctxt = ObjectReadContext.empty();
66+
67+
final byte[] data = "{ score:0.291e0 }".getBytes();
68+
IonSystem ion = IonSystemBuilder.standard().build();
69+
final IonValue ionFloat = ion.newFloat(Float.MAX_VALUE);
70+
IonReader reader = ionFloat.getSystem().newReader(data, 0, data.length);
71+
// Find the object
72+
reader.next();
73+
// Step into the object
74+
reader.stepIn();
75+
// Step next.
76+
reader.next();
77+
final IonParser floatParser = new IonFactory().createParser(ctxt, reader);
78+
Assert.assertEquals(JsonParser.NumberType.FLOAT, floatParser.getNumberType());
79+
}
6180
}

0 commit comments

Comments
 (0)