This commit is contained in:
Looly 2020-07-17 11:56:34 +08:00
parent 34a6a67023
commit ac81d9e750
5 changed files with 82 additions and 14 deletions

View File

@ -3,14 +3,16 @@
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
## 5.3.10 (2020-07-16) ## 5.3.10 (2020-07-17)
### 新特性 ### 新特性
* 【db 】 增加DbUtil.setReturnGeneratedKeyGlobalissue#I1NM0K@Gitee * 【db 】 增加DbUtil.setReturnGeneratedKeyGlobalissue#I1NM0K@Gitee
* 【core 】 增加DataSize和DataSizeUtilissue#967@Github * 【core 】 增加DataSize和DataSizeUtilissue#967@Github
* 【core 】 ImgUtil增加异常避免空指针issue#I1NKXG@Gitee
### Bug修复 ### Bug修复
* 【core 】 修复ZipUtil中finish位于循环内的问题issue#961@Github * 【core 】 修复ZipUtil中finish位于循环内的问题issue#961@Github
* 【core 】 修复CollUtil.page未越界检查的问题issue#I1O2LR@Gitee
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
## 5.3.9 (2020-07-12) ## 5.3.9 (2020-07-12)

View File

@ -235,10 +235,17 @@ public class ListUtil {
return new ArrayList<>(0); return new ArrayList<>(0);
} }
} }
if((pageNo * pageSize) > resultSize){
// 越界直接返回空
return new ArrayList<>(0);
}
final int[] startEnd = PageUtil.transToStartEnd(pageNo, pageSize); final int[] startEnd = PageUtil.transToStartEnd(pageNo, pageSize);
if (startEnd[1] > resultSize) { if (startEnd[1] > resultSize) {
startEnd[1] = resultSize; startEnd[1] = resultSize;
} }
return list.subList(startEnd[0], startEnd[1]); return list.subList(startEnd[0], startEnd[1]);
} }

View File

@ -1607,11 +1607,18 @@ public class ImgUtil {
* @since 3.2.2 * @since 3.2.2
*/ */
public static BufferedImage read(File imageFile) { public static BufferedImage read(File imageFile) {
BufferedImage result;
try { try {
return ImageIO.read(imageFile); result = ImageIO.read(imageFile);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type of file [" + imageFile.getName() + "] is not supported!");
}
return result;
} }
/** /**
@ -1633,11 +1640,18 @@ public class ImgUtil {
* @since 3.2.2 * @since 3.2.2
*/ */
public static BufferedImage read(InputStream imageStream) { public static BufferedImage read(InputStream imageStream) {
BufferedImage result;
try { try {
return ImageIO.read(imageStream); result = ImageIO.read(imageStream);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type is not supported!");
}
return result;
} }
/** /**
@ -1648,11 +1662,18 @@ public class ImgUtil {
* @since 3.2.2 * @since 3.2.2
*/ */
public static BufferedImage read(ImageInputStream imageStream) { public static BufferedImage read(ImageInputStream imageStream) {
BufferedImage result;
try { try {
return ImageIO.read(imageStream); result = ImageIO.read(imageStream);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type is not supported!");
}
return result;
} }
/** /**
@ -1663,11 +1684,18 @@ public class ImgUtil {
* @since 3.2.2 * @since 3.2.2
*/ */
public static BufferedImage read(URL imageUrl) { public static BufferedImage read(URL imageUrl) {
BufferedImage result;
try { try {
return ImageIO.read(imageUrl); result = ImageIO.read(imageUrl);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type of [" + imageUrl.toString() + "] is not supported!");
}
return result;
} }
/** /**
@ -1679,11 +1707,18 @@ public class ImgUtil {
* @since 3.1.2 * @since 3.1.2
*/ */
public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException { public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException {
ImageOutputStream result;
try { try {
return ImageIO.createImageOutputStream(out); result = ImageIO.createImageOutputStream(out);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type is not supported!");
}
return result;
} }
/** /**
@ -1695,11 +1730,18 @@ public class ImgUtil {
* @since 3.2.2 * @since 3.2.2
*/ */
public static ImageOutputStream getImageOutputStream(File outFile) throws IORuntimeException { public static ImageOutputStream getImageOutputStream(File outFile) throws IORuntimeException {
ImageOutputStream result;
try { try {
return ImageIO.createImageOutputStream(outFile); result = ImageIO.createImageOutputStream(outFile);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type of file [" + outFile.getName() + "] is not supported!");
}
return result;
} }
/** /**
@ -1711,11 +1753,18 @@ public class ImgUtil {
* @since 3.1.2 * @since 3.1.2
*/ */
public static ImageInputStream getImageInputStream(InputStream in) throws IORuntimeException { public static ImageInputStream getImageInputStream(InputStream in) throws IORuntimeException {
ImageOutputStream result;
try { try {
return ImageIO.createImageInputStream(in); result = ImageIO.createImageOutputStream(in);
} catch (IOException e) { } catch (IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
if (null == result) {
throw new IllegalArgumentException("Image type is not supported!");
}
return result;
} }
/** /**
@ -1778,7 +1827,7 @@ public class ImgUtil {
*/ */
public static String toHex(int r, int g, int b) { public static String toHex(int r, int g, int b) {
// rgb 小于 255 // rgb 小于 255
if(r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255){ if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
throw new IllegalArgumentException("RGB must be 0~255!"); throw new IllegalArgumentException("RGB must be 0~255!");
} }
return String.format("#%02X%02X%02X", r, g, b); return String.format("#%02X%02X%02X", r, g, b);

View File

@ -650,4 +650,14 @@ public class CollUtilTest {
Assert.assertEquals(Integer.valueOf(2), countMap.get("c")); Assert.assertEquals(Integer.valueOf(2), countMap.get("c"));
Assert.assertEquals(Integer.valueOf(1), countMap.get("d")); Assert.assertEquals(Integer.valueOf(1), countMap.get("d"));
} }
@Test
public void pageTest(){
List<Dict> objects = CollUtil.newArrayList();
for (int i = 0; i < 10; i++) {
objects.add(Dict.create().set("name", "姓名:" + i));
}
Assert.assertEquals(0, CollUtil.page(3, 5, objects).size());
}
} }

View File

@ -18,7 +18,7 @@
<properties> <properties>
<jython.version>2.7.2</jython.version> <jython.version>2.7.2</jython.version>
<luaj.version>3.0.1</luaj.version> <luaj.version>3.0.1</luaj.version>
<groovy.version>3.0.4</groovy.version> <groovy.version>3.0.2</groovy.version>
</properties> </properties>
<dependencies> <dependencies>