-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
18
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
the phrase `Long.valueOf(0).equals(0)` always returns false, similar issues in Integer,Double,Float implementation.
In the Implementation, the first line of code in `equals` function is an Exact type check,
this issue is become critical, specially, when other API wants to generate a collection of numbers, and for instance, they decide to create either List<Integer> or List<Long> according to data-range dynamically (such as Mongo library which store/retrieve data in `Document` format, load some data as Integer, Long or Double according to their value), in this case, contains function would not always work correct.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(Long.valueOf(0).equals(0));
ACTUAL -
false
---------- BEGIN SOURCE ----------
public class Main {
public static void main(String[] args) {
System.out.println(Long.valueOf(0).equals(0));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no explicit way to repair, and the neat method is to cast the list to desired type (re-new the List) or scan the list and cast an compare one-by-one, both methods are low performance way
FREQUENCY : always
Ubuntu 20.04
A DESCRIPTION OF THE PROBLEM :
the phrase `Long.valueOf(0).equals(0)` always returns false, similar issues in Integer,Double,Float implementation.
In the Implementation, the first line of code in `equals` function is an Exact type check,
this issue is become critical, specially, when other API wants to generate a collection of numbers, and for instance, they decide to create either List<Integer> or List<Long> according to data-range dynamically (such as Mongo library which store/retrieve data in `Document` format, load some data as Integer, Long or Double according to their value), in this case, contains function would not always work correct.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(Long.valueOf(0).equals(0));
ACTUAL -
false
---------- BEGIN SOURCE ----------
public class Main {
public static void main(String[] args) {
System.out.println(Long.valueOf(0).equals(0));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no explicit way to repair, and the neat method is to cast the list to desired type (re-new the List) or scan the list and cast an compare one-by-one, both methods are low performance way
FREQUENCY : always