Skip to content

JsonPrimitive with LazilyParsedNumber integers breaks contract for hashCode() #992

Closed

Description

@einarpehrson

While most types maintain consistency between equals() and hashCode() after string serialization and parsing (JsonElement#toString() + JsonParser#parse(String), integers do not. equals() returns true, but the hash codes are different.

  public void testEqualsIntegerAndLazilyParsedInteger() {
    MoreAsserts.assertEqualsAndHashCode(new JsonPrimitive(42), new JsonPrimitive(new LazilyParsedNumber("42")));
  }

Activity

  1. dwilches commented on Apr 10, 2020

    @dwilches

    Just got hit by this 3-year old bug.

  2. jblacker commented on May 14, 2020

    @jblacker

    Just got hit with this bug as well. Any chance this issue will get picked up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions