@@ -43,17 +43,22 @@ public void testBigDecimalCoercionInf() throws Exception
43
43
// [databind#4194]: should be able to, by configuration, fail coercing NaN to BigDecimal
44
44
public void testBigDecimalCoercionNaN () throws Exception
45
45
{
46
- _tryBigDecimalCoercionNaNWithOption (false );
46
+ JsonNode n = _tryBigDecimalCoercionNaNWithOption (false );
47
+ if (!n .isDouble ()) {
48
+ fail ("Expected DoubleNode, got: " +n .getClass ().getName ());
49
+ }
50
+ assertEquals (Double .NaN , n .doubleValue ());
47
51
48
52
try {
49
- _tryBigDecimalCoercionNaNWithOption (true );
50
- fail ("Should not pass" );
53
+ n = _tryBigDecimalCoercionNaNWithOption (true );
54
+ fail ("Should not pass without allowing coercion: produced JsonNode of type "
55
+ +n .getClass ().getName ());
51
56
} catch (InvalidFormatException e ) {
52
57
verifyException (e , "Cannot convert NaN" );
53
58
}
54
59
}
55
60
56
- private void _tryBigDecimalCoercionNaNWithOption (boolean isEnabled ) throws Exception
61
+ private JsonNode _tryBigDecimalCoercionNaNWithOption (boolean isEnabled ) throws Exception
57
62
{
58
63
JsonFactory factory = JsonFactory .builder ()
59
64
.enable (JsonReadFeature .ALLOW_NON_NUMERIC_NUMBERS )
@@ -64,11 +69,8 @@ private void _tryBigDecimalCoercionNaNWithOption(boolean isEnabled) throws Excep
64
69
65
70
final String value = "NaN" ;
66
71
// depending on option
67
- final JsonNode jsonNode = isEnabled
72
+ return isEnabled
68
73
? reader .with (JsonNodeFeature .FAIL_ON_NAN_TO_BIG_DECIMAL_COERCION ).readTree (value )
69
74
: reader .without (JsonNodeFeature .FAIL_ON_NAN_TO_BIG_DECIMAL_COERCION ).readTree (value );
70
-
71
- assertTrue ("Expected DoubleNode, got: " +jsonNode .getClass ().getName ()+": " +jsonNode , jsonNode .isDouble ());
72
- assertEquals (Double .NaN , jsonNode .doubleValue ());
73
75
}
74
76
}
0 commit comments