mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix NPE bug
This commit is contained in:
parent
ffed1d32fd
commit
1472cdc440
@ -24,7 +24,8 @@
|
||||
* 【core 】 修复SqlFormatter部分SQL空指针问题(issue#I3XS44@Gitee)
|
||||
* 【core 】 修复DateRange计算问题(issue#I3Y1US@Gitee)
|
||||
* 【core 】 修复BeanCopier中setFieldNameEditor失效问题(pr#349@Gitee)
|
||||
* 【core 】 修复ArrayUtil.indexOfSub查找bug(pr#349@Gitee)
|
||||
* 【core 】 修复ArrayUtil.indexOfSub查找bug(issue#1683@Github)
|
||||
* 【core 】 修复Node的权重比较空指针问题(issue#1681@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.hutool.core.lang.tree;
|
||||
|
||||
import cn.hutool.core.comparator.CompareUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -74,11 +76,11 @@ public interface Node<T> extends Comparable<Node<T>>, Serializable {
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "NullableProblems"})
|
||||
@Override
|
||||
default int compareTo(Node node) {
|
||||
final Comparable weight = this.getWeight();
|
||||
if (null != weight) {
|
||||
final Comparable weightOther = node.getWeight();
|
||||
return weight.compareTo(weightOther);
|
||||
if(null == node){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
final Comparable weight = this.getWeight();
|
||||
final Comparable weightOther = node.getWeight();
|
||||
return CompareUtil.compare(weight, weightOther);
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,4 @@ public class TreeBuilderTest {
|
||||
of.build();
|
||||
of.append(new ArrayList<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class TreeTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void sampleTree() {
|
||||
public void sampleTreeTest() {
|
||||
List<Tree<String>> treeList = TreeUtil.build(nodeList, "0");
|
||||
for (Tree<String> tree : treeList) {
|
||||
Assert.assertNotNull(tree);
|
||||
@ -43,7 +43,7 @@ public class TreeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tree() {
|
||||
public void treeTest() {
|
||||
|
||||
//配置
|
||||
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
|
||||
@ -66,5 +66,4 @@ public class TreeTest {
|
||||
|
||||
Assert.assertEquals(treeNodes.size(), 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user