johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (JOHNZON-123) JSONP spec compliance: JsonNumber.hashcode() is not spec compliant
Date Tue, 29 Aug 2017 11:10:00 GMT

     [ https://issues.apache.org/jira/browse/JOHNZON-123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mark Struberg resolved JOHNZON-123.
-----------------------------------
       Resolution: Fixed
         Assignee: Mark Struberg
    Fix Version/s: 1.1.3

> JSONP spec compliance: JsonNumber.hashcode() is not spec compliant
> ------------------------------------------------------------------
>
>                 Key: JOHNZON-123
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-123
>             Project: Johnzon
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>            Assignee: Mark Struberg
>             Fix For: 1.1.3
>
>
> From the JsonNumber javadoc [1]:
> {code}
> Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber
object is defined as the hash code of its bigDecimalValue() object.
> {code}
> Sample application
> {code}
> public final class Main {
>     public static void main(String[] args) {
>         JsonNumber a = Json.createObjectBuilder().add("a", 1).build().getJsonNumber("a");
>         JsonNumber b = Json.createObjectBuilder().add("b", 1.1).build().getJsonNumber("b");
>         
>         System.out.println("Hashcode equals (a): " + (a.hashCode() == a.bigDecimalValue().hashCode()));
>         System.out.println("Hashcode equals (b): " + (b.hashCode() == b.bigDecimalValue().hashCode()));
>     }
> }
> {code}
> Expected output:
> {code}
> Hashcode equals (a): true
> Hashcode equals (b): true
> {code}
> Actual output:
> {code}
> Hashcode equals (a): false
> Hashcode equals (b): false
> {code}
> [1] http://docs.oracle.com/javaee/7/api/javax/json/JsonNumber.html#hashCode--



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message