mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 looly(loolly@aliyun.com)
|
||||
* Copyright (c) 2023. looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
@@ -10,22 +10,24 @@
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.core.exception;
|
||||
package org.dromara.hutool.core.pool;
|
||||
|
||||
import org.dromara.hutool.core.exception.HutoolException;
|
||||
|
||||
/**
|
||||
* 未初始化异常
|
||||
* 对象池异常
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
public class NotInitedException extends HutoolException {
|
||||
private static final long serialVersionUID = 8247610319171014183L;
|
||||
public class PoolException extends HutoolException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param e 异常
|
||||
*/
|
||||
public NotInitedException(final Throwable e) {
|
||||
public PoolException(final Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
@@ -34,7 +36,7 @@ public class NotInitedException extends HutoolException {
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
public NotInitedException(final String message) {
|
||||
public PoolException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@@ -44,7 +46,7 @@ public class NotInitedException extends HutoolException {
|
||||
* @param messageTemplate 消息模板
|
||||
* @param params 参数
|
||||
*/
|
||||
public NotInitedException(final String messageTemplate, final Object... params) {
|
||||
public PoolException(final String messageTemplate, final Object... params) {
|
||||
super(messageTemplate, params);
|
||||
}
|
||||
|
||||
@@ -54,7 +56,7 @@ public class NotInitedException extends HutoolException {
|
||||
* @param message 消息
|
||||
* @param cause 被包装的子异常
|
||||
*/
|
||||
public NotInitedException(final String message, final Throwable cause) {
|
||||
public PoolException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@@ -66,7 +68,7 @@ public class NotInitedException extends HutoolException {
|
||||
* @param enableSuppression 是否启用抑制
|
||||
* @param writableStackTrace 堆栈跟踪是否应该是可写的
|
||||
*/
|
||||
public NotInitedException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
public PoolException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
@@ -77,7 +79,7 @@ public class NotInitedException extends HutoolException {
|
||||
* @param messageTemplate 消息模板
|
||||
* @param params 参数
|
||||
*/
|
||||
public NotInitedException(final Throwable cause, final String messageTemplate, final Object... params) {
|
||||
public PoolException(final Throwable cause, final String messageTemplate, final Object... params) {
|
||||
super(cause, messageTemplate, params);
|
||||
}
|
||||
}
|
@@ -12,11 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.core.pool.partition;
|
||||
|
||||
import org.dromara.hutool.core.exception.HutoolException;
|
||||
import org.dromara.hutool.core.pool.ObjectFactory;
|
||||
import org.dromara.hutool.core.pool.ObjectPool;
|
||||
import org.dromara.hutool.core.pool.PoolConfig;
|
||||
import org.dromara.hutool.core.pool.Poolable;
|
||||
import org.dromara.hutool.core.pool.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
@@ -99,7 +95,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
poolable = waitingPoll();
|
||||
if (null == poolable) {
|
||||
// 池空间达到最大值,但是无可用对象
|
||||
throw new HutoolException("Pool exhausted!");
|
||||
throw new PoolException("Pool exhausted!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +118,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
try {
|
||||
this.queue.put(poolable);
|
||||
} catch (final InterruptedException e) {
|
||||
throw new HutoolException(e);
|
||||
throw new PoolException(e);
|
||||
}
|
||||
} else {
|
||||
// 对象不可用
|
||||
@@ -150,7 +146,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
}
|
||||
total += increaseSize;
|
||||
} catch (final InterruptedException e) {
|
||||
throw new HutoolException(e);
|
||||
throw new PoolException(e);
|
||||
}
|
||||
return increaseSize;
|
||||
}
|
||||
@@ -208,9 +204,9 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
* 等待的时间取决于{@link PoolConfig#getMaxWait()},小于等于0时一直等待,否则等待给定毫秒数
|
||||
*
|
||||
* @return 取出的池对象
|
||||
* @throws HutoolException 中断异常
|
||||
* @throws PoolException 中断异常
|
||||
*/
|
||||
private Poolable<T> waitingPoll() throws HutoolException {
|
||||
private Poolable<T> waitingPoll() throws PoolException {
|
||||
final long maxWait = this.config.getMaxWait();
|
||||
try {
|
||||
if (maxWait <= 0) {
|
||||
@@ -218,7 +214,7 @@ public class PoolPartition<T> implements ObjectPool<T> {
|
||||
}
|
||||
return this.queue.poll(maxWait, TimeUnit.MILLISECONDS);
|
||||
} catch (final InterruptedException e) {
|
||||
throw new HutoolException(e);
|
||||
throw new PoolException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1325,7 +1325,7 @@ public class CharSequenceUtil extends StrValidator {
|
||||
* @see #appendIfMissing(CharSequence, CharSequence, CharSequence...)
|
||||
*/
|
||||
public static String addSuffixIfNot(final CharSequence str, final CharSequence suffix) {
|
||||
return appendIfMissing(str, suffix, suffix);
|
||||
return appendIfMissing(str, suffix);
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
Reference in New Issue
Block a user