Browse Source

fix null bug

Looly 5 years ago
parent
commit
e8c0a75e7f
2 changed files with 7 additions and 4 deletions
  1. 1 0
      CHANGELOG.md
  2. 6 4
      hutool-db/src/main/java/cn/hutool/db/DbUtil.java

+ 1 - 0
CHANGELOG.md

@@ -19,6 +19,7 @@
 * 【json   】     修复JSONConvert转换日期空指针问题(issue#I1F8M2@Gitee)
 * 【json   】     修复JSONConvert转换日期空指针问题(issue#I1F8M2@Gitee)
 * 【core   】     修复XML中带注释Xpath解析导致空指针问题(issue#I1F2WI@Gitee)
 * 【core   】     修复XML中带注释Xpath解析导致空指针问题(issue#I1F2WI@Gitee)
 * 【core   】     修复FileUtil.rename原文件无扩展名多点的问题(issue#839@Github)
 * 【core   】     修复FileUtil.rename原文件无扩展名多点的问题(issue#839@Github)
+* 【db     】     修复DbUtil.close可能存在的空指针问题(issue#847@Github)
 
 
 -------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------
 ## 5.3.1 (2020-04-17)
 ## 5.3.1 (2020-04-17)

+ 6 - 4
hutool-db/src/main/java/cn/hutool/db/DbUtil.java

@@ -152,10 +152,12 @@ public final class DbUtil {
 	 */
 	 */
 	public static void close(Object... objsToClose) {
 	public static void close(Object... objsToClose) {
 		for (Object obj : objsToClose) {
 		for (Object obj : objsToClose) {
-			if (obj instanceof AutoCloseable) {
-				IoUtil.close((AutoCloseable) obj);
-			} else {
-				log.warn("Object {} not a ResultSet or Statement or PreparedStatement or Connection!", obj.getClass().getName());
+			if(null != obj){
+				if (obj instanceof AutoCloseable) {
+					IoUtil.close((AutoCloseable) obj);
+				} else {
+					log.warn("Object {} not a ResultSet or Statement or PreparedStatement or Connection!", obj.getClass().getName());
+				}
 			}
 			}
 		}
 		}
 	}
 	}