Skip to content

Commit

Permalink
Remove workaround for old issue with a particular double (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Apr 20, 2022
1 parent 226dd97 commit 2b526bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ JSON library.
#733: Add `StreamReadCapability.EXACT_FLOATS` to indicate whether parser reports exact
floating-point values or not
(contributed Doug R)
#751: Remove workaround for old issue with a particular double
(contributed by @pjfanning)

2.13.3 (not yet released)

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/com/fasterxml/jackson/core/io/NumberInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

public final class NumberInput
{
/**
* Textual representation of a double constant that can cause nasty problems
* with JDK (see http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308).
*/
public final static String NASTY_SMALL_DOUBLE = "2.2250738585072012e-308";

/**
* Constants needed for parsing longs from basic int parsing methods
*/
Expand Down Expand Up @@ -300,13 +294,6 @@ public static double parseAsDouble(String s, double def)
}

public static double parseDouble(String s) throws NumberFormatException {
// [JACKSON-486]: avoid some nasty float representations... but should it be MIN_NORMAL or MIN_VALUE?
/* as per [JACKSON-827], let's use MIN_VALUE as it is available on all JDKs; normalized
* only in JDK 1.6. In practice, should not really matter.
*/
if (NASTY_SMALL_DOUBLE.equals(s)) {
return Double.MIN_VALUE;
}
return Double.parseDouble(s);
}

Expand Down
14 changes: 14 additions & 0 deletions src/test/java/com/fasterxml/jackson/core/io/TestNumberInput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.fasterxml.jackson.core.io;

public class TestNumberInput
extends com.fasterxml.jackson.core.BaseTest
{
public void testNastySmallDouble()
{
//relates to https://github.com/FasterXML/jackson-core/issues/750
//prior to jackson v2.14, this value used to be returned as Double.MIN_VALUE
final String nastySmallDouble = "2.2250738585072012e-308";
assertEquals(Double.parseDouble(nastySmallDouble), NumberInput.parseDouble(nastySmallDouble));
}
}

0 comments on commit 2b526bc

Please sign in to comment.