mirror of
				https://gitee.com/dromara/hutool.git
				synced 2025-10-31 08:26:57 +08:00 
			
		
		
		
	修改异常包装策略:运行时异常不包装,只包装非运行时异常
This commit is contained in:
		| @@ -2,11 +2,12 @@ | ||||
| # 🚀Changelog | ||||
|  | ||||
| ------------------------------------------------------------------------------------------------------------- | ||||
| # 5.8.22(2023-08-07) | ||||
| # 5.8.22(2023-08-08) | ||||
|  | ||||
| ### 🐣新特性 | ||||
| * 【core  】      NumberUtil.nullToZero增加重载(issue#I7PPD2@Gitee) | ||||
| * 【core  】      DesensitizedUtil增加清空策略(issue#I7PUJ2@Gitee) | ||||
| * 【all   】      修改异常包装策略:运行时异常不包装,只包装非运行时异常(issue#I7RJZT@Gitee) | ||||
|  | ||||
| ### 🐞Bug修复 | ||||
| * 【core  】      修复NumberUtil.toBigDecimal转换科学计数法问题(issue#3241@Github) | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package cn.hutool.cache.impl; | ||||
|  | ||||
| import cn.hutool.cache.Cache; | ||||
| import cn.hutool.cache.CacheListener; | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
| import cn.hutool.core.lang.func.Func0; | ||||
| import cn.hutool.core.lang.mutable.Mutable; | ||||
| import cn.hutool.core.lang.mutable.MutableObj; | ||||
| @@ -120,7 +121,9 @@ public abstract class AbstractCache<K, V> implements Cache<K, V> { | ||||
| 					try { | ||||
| 						v = supplier.call(); | ||||
| 					} catch (Exception e) { | ||||
| 						throw new RuntimeException(e); | ||||
| 						// issue#I7RJZT 运行时异常不做包装 | ||||
| 						throw ExceptionUtil.wrapRuntime(e); | ||||
| 						//throw new RuntimeException(e); | ||||
| 					} | ||||
| 					put(key, v, this.timeout); | ||||
| 				} else { | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.hutool.cache.impl; | ||||
|  | ||||
| import cn.hutool.cache.Cache; | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
| import cn.hutool.core.lang.func.Func0; | ||||
|  | ||||
| import java.util.Iterator; | ||||
| @@ -60,7 +61,7 @@ public class NoCache<K, V> implements Cache<K, V> { | ||||
| 		try { | ||||
| 			return (null == supplier) ? null : supplier.call(); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -531,7 +531,7 @@ public class IoUtil extends NioUtil { | ||||
| 			int i = in.available(); | ||||
| 			return readHex(in, Math.min(8192, in.available()), false); | ||||
| 		} catch (IOException e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw new IORuntimeException(e); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package cn.hutool.core.lang; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.collection.EnumerationIter; | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
| import cn.hutool.core.io.FileUtil; | ||||
| import cn.hutool.core.io.IORuntimeException; | ||||
| import cn.hutool.core.io.resource.ResourceUtil; | ||||
| @@ -398,7 +399,7 @@ public class ClassScanner implements Serializable { | ||||
| 			classesOfLoadError.add(className); | ||||
| 		} catch (Throwable e) { | ||||
| 			if (false == this.ignoreLoadError) { | ||||
| 				throw new RuntimeException(e); | ||||
| 				throw ExceptionUtil.wrapRuntime(e); | ||||
| 			} else { | ||||
| 				classesOfLoadError.add(className); | ||||
| 			} | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.hutool.core.lang; | ||||
|  | ||||
| import cn.hutool.core.collection.TransIter; | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
| import cn.hutool.core.lang.func.Func0; | ||||
| import cn.hutool.core.lang.mutable.Mutable; | ||||
| import cn.hutool.core.lang.mutable.MutableObj; | ||||
| @@ -110,7 +111,7 @@ public class SimpleCache<K, V> implements Iterable<Map.Entry<K, V>>, Serializabl | ||||
| 					try { | ||||
| 						v = supplier.call(); | ||||
| 					} catch (Exception e) { | ||||
| 						throw new RuntimeException(e); | ||||
| 						throw ExceptionUtil.wrapRuntime(e); | ||||
| 					} | ||||
| 					put(key, v); | ||||
| 				} | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -37,7 +39,7 @@ public interface Func<P, R> extends Serializable { | ||||
| 		try { | ||||
| 			return call(parameters); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -33,7 +35,7 @@ public interface Func0<R> extends Serializable { | ||||
| 		try { | ||||
| 			return call(); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -37,7 +39,7 @@ public interface Func1<P, R> extends Serializable { | ||||
| 		try { | ||||
| 			return call(parameter); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -35,7 +37,7 @@ public interface VoidFunc<P> extends Serializable { | ||||
| 		try { | ||||
| 			call(parameters); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -31,7 +33,7 @@ public interface VoidFunc0 extends Serializable { | ||||
| 		try { | ||||
| 			call(); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.hutool.core.lang.func; | ||||
|  | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
| @@ -33,7 +35,7 @@ public interface VoidFunc1<P> extends Serializable { | ||||
| 		try { | ||||
| 			call(parameter); | ||||
| 		} catch (Exception e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.hutool.db.sql; | ||||
|  | ||||
| import cn.hutool.core.collection.ArrayIter; | ||||
| import cn.hutool.core.exceptions.ExceptionUtil; | ||||
| import cn.hutool.core.lang.func.Func1; | ||||
| import cn.hutool.db.DbUtil; | ||||
| import cn.hutool.db.StatementUtil; | ||||
| @@ -299,7 +300,7 @@ public class SqlExecutor { | ||||
| 			if(e instanceof SQLException){ | ||||
| 				throw (SQLException) e; | ||||
| 			} | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw ExceptionUtil.wrapRuntime(e); | ||||
| 		} finally { | ||||
| 			DbUtil.close(ps); | ||||
| 		} | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.hutool.extra.ftp; | ||||
|  | ||||
| import cn.hutool.core.io.FileUtil; | ||||
| import cn.hutool.core.io.IORuntimeException; | ||||
| import cn.hutool.core.io.IoUtil; | ||||
| import cn.hutool.core.lang.Console; | ||||
| import cn.hutool.extra.ssh.Sftp; | ||||
| @@ -108,7 +109,7 @@ public class FtpTest { | ||||
| 				} | ||||
| 			} | ||||
| 		} catch (final IOException e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw new IORuntimeException(e); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| package cn.hutool.poi.excel; | ||||
|  | ||||
| import cn.hutool.core.io.IORuntimeException; | ||||
| import cn.hutool.poi.excel.cell.CellUtil; | ||||
| import org.apache.poi.ss.usermodel.Cell; | ||||
| import org.apache.poi.ss.usermodel.Row; | ||||
| @@ -42,7 +43,7 @@ public class IssueI6MBS5Test { | ||||
| 			CellUtil.setComment(cell, "commonText", "ascend", null); | ||||
| 			workbook.write(Files.newOutputStream(file.toPath())); | ||||
| 		} catch (final IOException e) { | ||||
| 			throw new RuntimeException(e); | ||||
| 			throw new IORuntimeException(e); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Looly
					Looly