Skip to content

Commit 2b526bc

Browse files
authored
Remove workaround for old issue with a particular double (#751)
1 parent 226dd97 commit 2b526bc

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ JSON library.
2323
#733: Add `StreamReadCapability.EXACT_FLOATS` to indicate whether parser reports exact
2424
floating-point values or not
2525
(contributed Doug R)
26+
#751: Remove workaround for old issue with a particular double
27+
(contributed by @pjfanning)
2628

2729
2.13.3 (not yet released)
2830

src/main/java/com/fasterxml/jackson/core/io/NumberInput.java

-13
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
public final class NumberInput
66
{
7-
/**
8-
* Textual representation of a double constant that can cause nasty problems
9-
* with JDK (see http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308).
10-
*/
11-
public final static String NASTY_SMALL_DOUBLE = "2.2250738585072012e-308";
12-
137
/**
148
* Constants needed for parsing longs from basic int parsing methods
159
*/
@@ -300,13 +294,6 @@ public static double parseAsDouble(String s, double def)
300294
}
301295

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.fasterxml.jackson.core.io;
2+
3+
public class TestNumberInput
4+
extends com.fasterxml.jackson.core.BaseTest
5+
{
6+
public void testNastySmallDouble()
7+
{
8+
//relates to https://github.com/FasterXML/jackson-core/issues/750
9+
//prior to jackson v2.14, this value used to be returned as Double.MIN_VALUE
10+
final String nastySmallDouble = "2.2250738585072012e-308";
11+
assertEquals(Double.parseDouble(nastySmallDouble), NumberInput.parseDouble(nastySmallDouble));
12+
}
13+
}
14+

0 commit comments

Comments
 (0)