eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.26k stars 2.07k forks source link

fix-JsonObject#equals-method-fails-when-comparing-integers-with-floats #5192

Closed sai-manohar-veerubhotla closed 5 months ago

sai-manohar-veerubhotla commented 5 months ago

Motivation: The motivation is to fix the bug: https://github.com/eclipse-vertx/vert.x/issues/5185

Context: The current implementation of JsonObject#equals fails to equate numeric types correctly, leading to false comparisons:

  1. 2f is not considered equal to 2.
  2. 2D is not considered equal to 2.

Changes: This PR updates JsonObject#equals to correctly handle comparisons between different numeric types (float, double, intege, long), ensuring logical equivalence where expected. Additionally, new assertions have been added to JsonObjectTest#testNumberEquality to validate these changes.

This PR tries to fix exactly the same by modifying the JsonObject#equals. Adds new assertions to JsonObjectTest#testNumberEquality.