-
Notifications
You must be signed in to change notification settings - Fork 544
Closed
Description
I ran into a NumberFormatException when trying to decode user-provided strings as double values with circe v0.14.5:
val userInput = """"E7""""
io.circe.parser.parse(userInput).flatMap(_.as[Double]) // java.lang.NumberFormatException: Zero length BigIntegerThe actual culprit is BiggerDecimal.parseBiggerDecimalUnsafe which is used by several decoders. The behaviour of this method has changed between releases v0.14.2 and v0.14.3 (regardless of the Scala version):
v0.14.2
echo 'print(io.circe.numbers.BiggerDecimal.parseBiggerDecimalUnsafe("E7"))' \
| scala-cli -S 3.2.2 -q --dependency "io.circe::circe-core::0.14.2" _.sc
nullv0.14.3
echo 'print(io.circe.numbers.BiggerDecimal.parseBiggerDecimalUnsafe("E7"))' \
| scala-cli -S 3.2.2 -q --dependency "io.circe::circe-core::0.14.3" _.sc
Exception in thread "main" java.lang.ExceptionInInitializerError
at stdin_sc$.main(stdin:17)
at stdin_sc.main(stdin)
Caused by: java.lang.NumberFormatException: Zero length BigInteger
at java.base/java.math.BigInteger.<init>(BigInteger.java:484)
at java.base/java.math.BigInteger.<init>(BigInteger.java:672)
at io.circe.numbers.BiggerDecimal$.parseBiggerDecimalUnsafe(BiggerDecimal.scala:359)
at stdin$.<clinit>(stdin:1)
... 2 moreMetadata
Metadata
Assignees
Labels
No labels