[ https://issues.apache.org/jira/browse/JOHNZON-120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Romain Manni-Bucau resolved JOHNZON-120. ---------------------------------------- Resolution: Fixed Assignee: Romain Manni-Bucau Fix Version/s: 1.1.2 > JSONP spec compliance: JsonNumber.int/longValueExact() does not throw > ArithmeticException > ----------------------------------------------------------------------------------------- > > Key: JOHNZON-120 > URL: https://issues.apache.org/jira/browse/JOHNZON-120 > Project: Johnzon > Issue Type: Bug > Affects Versions: 1.0.0 > Reporter: Svetlin Zarev > Assignee: Romain Manni-Bucau > Fix For: 1.1.2 > > > According to the JSONP spec, if the json number has non zero fractional part, > intValueExact() & longValueExcat() must throw Arithmetic exception: [1], [2] > {code} > * java.lang.ArithmeticException - if the number has a nonzero fractional part > or if it does not fit in an int > * java.lang.ArithmeticException - if the number has a non-zero fractional > part or if it does not fit in a long > {code} > Sample application to reproduce the issue: > {code} > public final class Main { > public static void main(String[] args) { > JsonArray array = Json.createArrayBuilder() > .add(12345.6489) > .build(); > boolean success = false; > try { > int value = array > .getJsonNumber(0) > .intValueExact(); > } catch (ArithmeticException ex) { > success = true; > } > System.out.println("Caught expected exception: " + success); > } > {code} > [1] > http://docs.oracle.com/javaee/7/api/javax/json/JsonNumber.html#intValueExact-- > [2] > http://docs.oracle.com/javaee/7/api/javax/json/JsonNumber.html#longValueExact-- -- This message was sent by Atlassian JIRA (v6.3.15#6346)