You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The file path is org.zkoss.lang.Comparables.
In our test case, we pass compare0 and compare1 into the functions whose api is max() and min(). Inside these api, an exception occurs when a null pointer is referenced for comparison
source code:
@SuppressWarnings ("unchecked")
public static final Comparable min (Comparable a,Comparable b){
return (a.compareTo(b)<0)?a b;
}
@SuppressWarnings("unchecked")
public static final Comparable max (Comparable a,Comparable b){
return (a.compareTo(b)<0)?b : a;
}
test code:
@Test
public void test _min_5_5() throws NoSuchFieldException, IllegalAccessException{
java.lang.Comparable<java.lang.object>comparable0=null;
java.lang.Comparable<java.lang.Object>comparable1=null;
org.zkoss.lang.Comparables.min(comparable0,comparable1);
}
@Test
public void test _max_1_6() throws NoSuchFieldException,IllegalAccessException{
java.lang.Comparable<java.lang.Object>comparable0=null;
java.lang.Comparable<java.lang.Object>comparable1=null;
org.zkoss.lang.Comparables.max (comparable0,comparable1);
test results:
java.lang.NullPointerException:Cannot invoke "java.lang.Comparable.compareTo(Object)"because "a"is null
at org.zkoss.lang.Comparables.min(Comparables.java:33)
at org.zkoss.lang.Comparables_Test.test_min_1_1(Comparables_Test.java:13)
The text was updated successfully, but these errors were encountered:
Cici-Musse-Lee
changed the title
“NullPointerException”The number passed in the api is min() is a null pointer.
“NullPointerException”The number passed in the api is min() and max() is a null pointer.
May 31, 2022
The file path is org.zkoss.lang.Comparables.
In our test case, we pass compare0 and compare1 into the functions whose api is max() and min(). Inside these api, an exception occurs when a null pointer is referenced for comparison
source code:
test code:
test results:
The text was updated successfully, but these errors were encountered: