mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 13:34:09 +08:00
fix #I54TZ9
This commit is contained in:
parent
3329d60fff
commit
d874b4282d
@ -6,8 +6,11 @@
|
||||
# 5.8.0.M5 (2022-04-27)
|
||||
|
||||
### ❌不兼容特性
|
||||
|
||||
### 🐣新特性
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【db 】 修复RedisDS无法设置maxWaitMillis问题(issue#I54TZ9@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -38,7 +38,8 @@ public class TreeUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建单root节点树
|
||||
* 构建单root节点树<br>
|
||||
* 它会生成一个以指定ID为ID的空的节点,然后逐级增加子节点。
|
||||
*
|
||||
* @param <E> ID类型
|
||||
* @param list 源数据集合
|
||||
@ -63,7 +64,8 @@ public class TreeUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建单root节点树
|
||||
* 构建单root节点树<br>
|
||||
* 它会生成一个以指定ID为ID的空的节点,然后逐级增加子节点。
|
||||
*
|
||||
* @param <T> 转换的实体 为数据源里的对象类型
|
||||
* @param <E> ID类型
|
||||
@ -107,7 +109,8 @@ public class TreeUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建单root节点树
|
||||
* 构建单root节点树<br>
|
||||
* 它会生成一个以指定ID为ID的空的节点,然后逐级增加子节点。
|
||||
*
|
||||
* @param <T> 转换的实体 为数据源里的对象类型
|
||||
* @param <E> ID类型
|
||||
@ -137,7 +140,8 @@ public class TreeUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 单点树构建,按照权重排序
|
||||
* 单点树构建,按照权重排序<br>
|
||||
* 它会生成一个以指定ID为ID的空的节点,然后逐级增加子节点。
|
||||
*
|
||||
* @param <E> ID类型
|
||||
* @param map 源数据Map
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.hutool.core.lang.tree;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Issue2279Test {
|
||||
|
||||
@Test
|
||||
public void buildSingleTest() {
|
||||
List<TestTree> list = ListUtil.of(
|
||||
// 模拟数据
|
||||
new TestTree(1, 0, 1, 1),
|
||||
new TestTree(2, 1, 2, 2),
|
||||
new TestTree(3, 1, 3, 3),
|
||||
new TestTree(4, 2, 4, 4)
|
||||
);
|
||||
|
||||
List<Tree<String>> stringTree = TreeUtil.build(list, "0",
|
||||
(object, treeNode) -> {
|
||||
treeNode.setId(object.getId());
|
||||
treeNode.setName(object.getName());
|
||||
treeNode.setParentId(object.getPid());
|
||||
treeNode.putExtra("extra1",object.getExtra1());
|
||||
}
|
||||
);
|
||||
|
||||
final Tree<String> result = stringTree.get(0);
|
||||
Assert.assertEquals(2, result.getChildren().size());
|
||||
}
|
||||
|
||||
@Data
|
||||
static class TestTree {
|
||||
private String id;
|
||||
private String pid;
|
||||
private String name;
|
||||
private String extra1;
|
||||
|
||||
public TestTree(int id, int pid, int name, int extra1) {
|
||||
this.id = String.valueOf(id);
|
||||
this.pid = String.valueOf(pid);
|
||||
this.name = String.valueOf(name);
|
||||
this.extra1 = String.valueOf(extra1);
|
||||
}
|
||||
}
|
||||
}
|
@ -94,6 +94,12 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
<version>${dbcp2.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -108,10 +114,6 @@
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -174,6 +176,12 @@
|
||||
<artifactId>clickhouse-jdbc</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -105,6 +105,13 @@ public class RedisDS implements Closeable, Serializable {
|
||||
setting.toBean(group, config);
|
||||
}
|
||||
|
||||
//issue#I54TZ9
|
||||
final Long maxWaitMillis = setting.getLong("maxWaitMillis");
|
||||
if(null != maxWaitMillis){
|
||||
//noinspection deprecation
|
||||
config.setMaxWaitMillis(maxWaitMillis);
|
||||
}
|
||||
|
||||
this.pool = new JedisPool(config,
|
||||
// 地址
|
||||
setting.getStr("host", group, Protocol.DEFAULT_HOST),
|
||||
|
Loading…
Reference in New Issue
Block a user