Fix potential NPE by checking for object identity instead of comparing one property only
This commit is contained in:
parent
8ac3334a04
commit
6bb871786e
|
@ -174,7 +174,7 @@ public class ThreadUtilsTest {
|
||||||
try {
|
try {
|
||||||
t1.start();
|
t1.start();
|
||||||
t2.start();
|
t2.start();
|
||||||
assertEquals(t1.getName(), ThreadUtils.findThreadById(t1.getId()).getName());
|
assertSame(t1, ThreadUtils.findThreadById(t1.getId()));
|
||||||
assertSame(t2, ThreadUtils.findThreadById(t2.getId()));
|
assertSame(t2, ThreadUtils.findThreadById(t2.getId()));
|
||||||
} finally {
|
} finally {
|
||||||
t1.interrupt();
|
t1.interrupt();
|
||||||
|
@ -261,8 +261,8 @@ public class ThreadUtilsTest {
|
||||||
try {
|
try {
|
||||||
t1.start();
|
t1.start();
|
||||||
t2.start();
|
t2.start();
|
||||||
assertEquals(t1.getName(), ThreadUtils.findThreadById(t1.getId(),"thread_group_DDZZ99__").getName());
|
assertSame(t1, ThreadUtils.findThreadById(t1.getId(),"thread_group_DDZZ99__"));
|
||||||
assertEquals(t2.getName(), ThreadUtils.findThreadById(t2.getId(),"thread_group_DDZZ99__").getName());
|
assertSame(t2, ThreadUtils.findThreadById(t2.getId(),"thread_group_DDZZ99__"));
|
||||||
assertNull(ThreadUtils.findThreadById(nonExistingId,"non_existent_thread_group_JJHHZZ__"));
|
assertNull(ThreadUtils.findThreadById(nonExistingId,"non_existent_thread_group_JJHHZZ__"));
|
||||||
assertNull(ThreadUtils.findThreadById(nonExistingId,"thread_group_DDZZ99__"));
|
assertNull(ThreadUtils.findThreadById(nonExistingId,"thread_group_DDZZ99__"));
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue