mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +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>
|
||||
|
@ -13,7 +13,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Jedis数据源
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 3.2.3
|
||||
*/
|
||||
@ -30,7 +30,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
// --------------------------------------------------------------------------------- Static method start
|
||||
/**
|
||||
* 创建RedisDS,使用默认配置文件,默认分组
|
||||
*
|
||||
*
|
||||
* @return RedisDS
|
||||
*/
|
||||
public static RedisDS create() {
|
||||
@ -39,7 +39,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 创建RedisDS,使用默认配置文件
|
||||
*
|
||||
*
|
||||
* @param group 配置文件中配置分组
|
||||
* @return RedisDS
|
||||
*/
|
||||
@ -49,7 +49,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 创建RedisDS
|
||||
*
|
||||
*
|
||||
* @param setting 配置文件
|
||||
* @param group 配置文件中配置分组
|
||||
* @return RedisDS
|
||||
@ -68,7 +68,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 构造,使用默认配置文件
|
||||
*
|
||||
*
|
||||
* @param group 配置文件中配置分组
|
||||
*/
|
||||
public RedisDS(String group) {
|
||||
@ -77,7 +77,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param setting 配置文件
|
||||
* @param group 配置文件中配置分组
|
||||
*/
|
||||
@ -88,7 +88,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 初始化Jedis客户端
|
||||
*
|
||||
*
|
||||
* @param group Redis服务器信息分组
|
||||
* @return this
|
||||
*/
|
||||
@ -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),
|
||||
@ -130,7 +137,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 从资源池中获取{@link Jedis}
|
||||
*
|
||||
*
|
||||
* @return {@link Jedis}
|
||||
*/
|
||||
public Jedis getJedis() {
|
||||
@ -139,7 +146,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 从Redis中获取值
|
||||
*
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
@ -151,7 +158,7 @@ public class RedisDS implements Closeable, Serializable {
|
||||
|
||||
/**
|
||||
* 从Redis中获取值
|
||||
*
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 状态码
|
||||
@ -161,10 +168,10 @@ public class RedisDS implements Closeable, Serializable {
|
||||
return jedis.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从Redis中删除多个值
|
||||
*
|
||||
*
|
||||
* @param keys 需要删除值对应的键列表
|
||||
* @return 删除个数,0表示无key可删除
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user