diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f57d8372..9bb4fc9a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * 【core 】 BooleanConverter增加数字转换规则(issue#I1R2AB@Gitee) * 【poi 】 sax方式读取增加一个sheet结束的回调(issue#155@Gitee) * 【db 】 增加BeeCP连接池支持 +* 【core 】 改进Img.pressImage方法,避免变色问题(issue#1001@Github) ### Bug修复# * 【core 】 修复原始类型转换时,转换失败没有抛出异常的问题 diff --git a/hutool-core/src/main/java/cn/hutool/core/img/Img.java b/hutool-core/src/main/java/cn/hutool/core/img/Img.java index d16de3a45..a369b620b 100644 --- a/hutool-core/src/main/java/cn/hutool/core/img/Img.java +++ b/hutool-core/src/main/java/cn/hutool/core/img/Img.java @@ -507,7 +507,7 @@ public class Img implements Serializable { public Img pressImage(Image pressImg, Rectangle rectangle, float alpha) { final Image targetImg = getValidSrcImg(); - this.targetImage = draw(ImgUtil.toBufferedImage(targetImg), pressImg, rectangle, alpha); + this.targetImage = draw(ImgUtil.toBufferedImage(targetImg, this.targetImageType), pressImg, rectangle, alpha); return this; } diff --git a/hutool-db/src/main/java/cn/hutool/db/ds/bee/BeeDSFactory.java b/hutool-db/src/main/java/cn/hutool/db/ds/bee/BeeDSFactory.java index 59cc20d6c..7a4bdd13a 100644 --- a/hutool-db/src/main/java/cn/hutool/db/ds/bee/BeeDSFactory.java +++ b/hutool-db/src/main/java/cn/hutool/db/ds/bee/BeeDSFactory.java @@ -33,6 +33,11 @@ public class BeeDSFactory extends AbstractDSFactory { final BeeDataSourceConfig beeConfig = new BeeDataSourceConfig(driver, jdbcUrl, user, pass); poolSetting.toBean(beeConfig); + // 修复BeeCP默认参数无效问题 + if(beeConfig.getBorrowConcurrentSize() > beeConfig.getMaxActive()){ + beeConfig.setMaxActive(beeConfig.getBorrowConcurrentSize() + 1); + } + // remarks等特殊配置,since 5.3.8 String connValue; for (String key : KEY_CONN_PROPS) { diff --git a/hutool-db/src/test/java/cn/hutool/db/DsTest.java b/hutool-db/src/test/java/cn/hutool/db/DsTest.java index 68da70ae8..870f61190 100644 --- a/hutool-db/src/test/java/cn/hutool/db/DsTest.java +++ b/hutool-db/src/test/java/cn/hutool/db/DsTest.java @@ -2,6 +2,7 @@ package cn.hutool.db; import cn.hutool.core.collection.CollUtil; import cn.hutool.db.ds.DSFactory; +import cn.hutool.db.ds.bee.BeeDSFactory; import cn.hutool.db.ds.c3p0.C3p0DSFactory; import cn.hutool.db.ds.dbcp.DbcpDSFactory; import cn.hutool.db.ds.druid.DruidDSFactory; @@ -59,6 +60,15 @@ public class DsTest { Assert.assertTrue(CollUtil.isNotEmpty(all)); } + @Test + public void beeCPDsTest() throws SQLException { + DSFactory.setCurrentDSFactory(new BeeDSFactory()); + DataSource ds = DSFactory.get("test"); + Db db = Db.use(ds); + List all = db.findAll("user"); + Assert.assertTrue(CollUtil.isNotEmpty(all)); + } + @Test public void dbcpDsTest() throws SQLException { DSFactory.setCurrentDSFactory(new DbcpDSFactory()); diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelReader.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelReader.java index dc34ec79d..308de73b7 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelReader.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelReader.java @@ -511,12 +511,12 @@ public class ExcelReader extends ExcelBase { * @return 转换别名列表 */ private List aliasHeader(List headerList) { - final int size = headerList.size(); - final ArrayList result = new ArrayList<>(size); - if (CollUtil.isEmpty(headerList)) { - return result; + if(CollUtil.isEmpty(headerList)){ + return new ArrayList<>(0); } + final int size = headerList.size(); + final ArrayList result = new ArrayList<>(size); for (int i = 0; i < size; i++) { result.add(aliasHeader(headerList.get(i), i)); } diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/RowUtil.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/RowUtil.java index 1a5684ed7..cbeb149db 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/RowUtil.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/RowUtil.java @@ -1,27 +1,27 @@ package cn.hutool.poi.excel; -import java.util.ArrayList; -import java.util.List; - +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.poi.excel.cell.CellEditor; +import cn.hutool.poi.excel.cell.CellUtil; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; -import cn.hutool.core.util.StrUtil; -import cn.hutool.poi.excel.cell.CellEditor; -import cn.hutool.poi.excel.cell.CellUtil; +import java.util.ArrayList; +import java.util.List; /** * Excel中的行{@link Row}封装工具类 - * + * * @author looly * @since 4.0.7 */ public class RowUtil { /** * 获取已有行或创建新行 - * - * @param sheet Excel表 + * + * @param sheet Excel表 * @param rowIndex 行号 * @return {@link Row} * @since 4.0.2 @@ -36,23 +36,38 @@ public class RowUtil { /** * 读取一行 - * - * @param row 行 + * + * @param row 行 * @param cellEditor 单元格编辑器 * @return 单元格值列表 */ public static List readRow(Row row, CellEditor cellEditor) { + return readRow(row, 0, Short.MAX_VALUE, cellEditor); + } + + /** + * 读取一行 + * + * @param row 行 + * @param startCellNumInclude 起始单元格号,0开始(包含) + * @param endCellNumInclude 结束单元格号,0开始(包含) + * @param cellEditor 单元格编辑器 + * @return 单元格值列表 + */ + public static List readRow(Row row, int startCellNumInclude, int endCellNumInclude, CellEditor cellEditor) { if (null == row) { return new ArrayList<>(0); } - final short length = row.getLastCellNum(); - if (length < 0) { - return new ArrayList<>(0); + final short rowLength = row.getLastCellNum(); + if (rowLength < 0) { + return ListUtil.empty(); } - final List cellValues = new ArrayList<>(length); + + final int size = Math.min(endCellNumInclude + 1, rowLength); + final List cellValues = new ArrayList<>(size); Object cellValue; boolean isAllNull = true; - for (short i = 0; i < length; i++) { + for (int i = startCellNumInclude; i < size; i++) { cellValue = CellUtil.getCellValue(row.getCell(i), cellEditor); isAllNull &= StrUtil.isEmptyIfStr(cellValue); cellValues.add(cellValue); @@ -60,16 +75,16 @@ public class RowUtil { if (isAllNull) { // 如果每个元素都为空,则定义为空行 - return new ArrayList<>(0); + return ListUtil.empty(); } return cellValues; } /** * 写一行数据 - * - * @param row 行 - * @param rowData 一行的数据 + * + * @param row 行 + * @param rowData 一行的数据 * @param styleSet 单元格样式集,包括日期等样式 * @param isHeader 是否为标题行 */