Skip to content

Double. NEGATIVE_INFINITY parses to string but fails to serialize back to a double #176

@timlevett

Description

@timlevett

Hi, see failing test below

  @Test
  public void testInfinity() {
    String serializedString = JsonStream.serialize(Double.NEGATIVE_INFINITY);
    Double deserializedInfinity = JsonIterator.deserialize(serializedString, Double.class);

    assertTrue(deserializedInfinity == Double.NEGATIVE_INFINITY);
  }

Including error

com.jsoniter.spi.JsonException: readDoubleSlowPath: java.lang.NumberFormatException: empty String, head: 1, peek: -, buf: -Infinity

	at com.jsoniter.JsonIterator.reportError(JsonIterator.java:136)
	at com.jsoniter.IterImplForStreaming.readDoubleSlowPath(IterImplForStreaming.java:545)
	at com.jsoniter.IterImpl.readDouble(IterImpl.java:492)
	at com.jsoniter.IterImplNumber.readDouble(IterImplNumber.java:67)
	at com.jsoniter.JsonIterator.readDouble(JsonIterator.java:230)
	at com.jsoniter.CodegenImplNative$2$4.decode(CodegenImplNative.java:61)
	at com.jsoniter.JsonIterator.read(JsonIterator.java:385)
	at com.jsoniter.JsonIterator.read(JsonIterator.java:375)
	at com.jsoniter.JsonIterator.deserialize(JsonIterator.java:441)
	at com.jsoniter.JsonIterator.deserialize(JsonIterator.java:411)
	at com.tci.core.probe.serialization.ProbeSerializationTest.testInfinity(ProbeSerializationTest.java:130)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions