Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for old issue with a particular double #751

Merged
merged 2 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}