diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e3452a2..49552a7c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * 【core 】 修复urlWithParamIfGet函数逻辑问题(issue#I50IUD@Gitee) * 【core 】 修复IoUtil.readBytes限制长度读取问题(issue#2230@Github) * 【http 】 修复HttpRequest中编码对URL无效的问题(issue#I50NHQ@Gitee) +* 【poi 】 修复读取excel抛NPE错误(pr#2234@Github) ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java b/hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java index b0c741fa7..585dd5aa8 100644 --- a/hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java +++ b/hutool-db/src/main/java/cn/hutool/db/handler/HandleHelper.java @@ -23,7 +23,7 @@ import java.util.Map; /** * 数据结果集处理辅助类 - * + * * @author loolly * */ @@ -60,7 +60,7 @@ public class HandleHelper { @SuppressWarnings("unchecked") public static T handleRow(int columnCount, ResultSetMetaData meta, ResultSet rs, Class beanClass) throws SQLException { Assert.notNull(beanClass, "Bean Class must be not null !"); - + if(beanClass.isArray()) { //返回数组 final Class componentType = beanClass.getComponentType(); @@ -81,7 +81,7 @@ public class HandleHelper { final Object[] objRow = handleRow(columnCount, meta, rs, Object[].class); return (T) StrUtil.join(", ", objRow); } - + //普通bean final T bean = ReflectUtil.newInstanceIfPossible(beanClass); //忽略字段大小写 @@ -108,7 +108,7 @@ public class HandleHelper { /** * 处理单条数据 - * + * * @param columnCount 列数 * @param meta ResultSetMetaData * @param rs 数据集 @@ -118,10 +118,10 @@ public class HandleHelper { public static Entity handleRow(int columnCount, ResultSetMetaData meta, ResultSet rs) throws SQLException { return handleRow(columnCount, meta, rs, false); } - + /** * 处理单条数据 - * + * * @param columnCount 列数 * @param meta ResultSetMetaData * @param rs 数据集 @@ -136,7 +136,7 @@ public class HandleHelper { /** * 处理单条数据 - * + * * @param Entity及其子对象 * @param row Entity对象 * @param columnCount 列数 @@ -199,7 +199,7 @@ public class HandleHelper { /** * 处理多条数据 - * + * * @param 集合类型 * @param rs 数据集 * @param collection 数据集 @@ -209,10 +209,10 @@ public class HandleHelper { public static > T handleRs(ResultSet rs, T collection) throws SQLException { return handleRs(rs, collection, false); } - + /** * 处理多条数据 - * + * * @param 集合类型 * @param rs 数据集 * @param collection 数据集 @@ -234,7 +234,7 @@ public class HandleHelper { /** * 处理多条数据并返回一个Bean列表 - * + * * @param 集合元素类型 * @param 集合类型 * @param rs 数据集 @@ -259,8 +259,7 @@ public class HandleHelper { /** * 获取字段值
* 针对日期时间等做单独处理判断 - * - * @param 返回类型 + * * @param rs {@link ResultSet} * @param columnIndex 字段索引 * @param type 字段类型,默认Object @@ -268,7 +267,7 @@ public class HandleHelper { * @return 字段值 * @throws SQLException SQL异常 */ - private static Object getColumnValue(ResultSet rs, int columnIndex, int type, Type targetColumnType) throws SQLException { + private static Object getColumnValue(ResultSet rs, int columnIndex, int type, Type targetColumnType) throws SQLException { Object rawValue = null; switch (type) { case Types.TIMESTAMP: diff --git a/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelReadTest.java b/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelReadTest.java index 264b188e8..bb528e197 100644 --- a/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelReadTest.java +++ b/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelReadTest.java @@ -245,9 +245,9 @@ public class ExcelReadTest { Assert.assertEquals("", objects.get(2)); } - @Test(expected = NullPointerException.class) - @Ignore + @Test public void readColumnNPETest() { + // https://github.com/dromara/hutool/pull/2234 ExcelReader reader = ExcelUtil.getReader(ResourceUtil.getStream("read_row_npe.xlsx")); reader.readColumn(0, 1); }