mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix pool bug
This commit is contained in:
@@ -20,6 +20,7 @@ import org.dromara.hutool.core.io.IoUtil;
|
||||
import org.dromara.hutool.core.pool.ObjectFactory;
|
||||
import org.dromara.hutool.core.pool.ObjectPool;
|
||||
import org.dromara.hutool.core.pool.Poolable;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.dromara.hutool.core.thread.ThreadUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -117,6 +118,12 @@ public class PartitionObjectPool<T> implements ObjectPool<T> {
|
||||
IoUtil.closeQuietly(this.partitions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StrUtil.format("PartitionObjectPool: total: {}, idle: {}, active: {}",
|
||||
getTotal(), getIdleCount(), getActiveCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建阻塞队列,默认为{@link ArrayBlockingQueue}<br>
|
||||
* 如果需要自定义队列类型,子类重写此方法
|
||||
|
@@ -81,7 +81,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
// 检查是否超过最长空闲时间
|
||||
final long maxIdle = this.config.getMaxIdle();
|
||||
if (maxIdle <= 0 || poolable.getIdle() <= maxIdle) {
|
||||
return poolable.getRaw();
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,11 +188,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
return wrapPoolable(t);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Poolable<T> wrapPoolable(final T t) {
|
||||
if (t instanceof Poolable) {
|
||||
return (Poolable<T>) t;
|
||||
}
|
||||
return new PartitionPoolable<>(t, this);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user