From df92485aded78da32d5243740c335e073ec13e4e Mon Sep 17 00:00:00 2001 From: hanshuai <13546606929@163.com> Date: Mon, 7 Sep 2020 15:03:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BA=94=E8=AF=A5=E6=98=AF=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hutool-core/src/main/java/cn/hutool/core/util/PhoneUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/util/PhoneUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/PhoneUtil.java index 9b05578a4..402255992 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/PhoneUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/PhoneUtil.java @@ -17,7 +17,7 @@ public class PhoneUtil { /** * 座机号码 */ - private static Pattern TEL = Pattern.compile("0\\d{2,3}-[1-9]\\d{6,7}"); + private static final Pattern TEL = Pattern.compile("0\\d{2,3}-[1-9]\\d{6,7}"); /** * 验证是否为手机号码(中国) From 53a7b4bf6cc024dbe27e17cf705ae5bf33485833 Mon Sep 17 00:00:00 2001 From: hanshuai <13546606929@163.com> Date: Mon, 7 Sep 2020 15:35:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B5=AE=E7=82=B9=E6=95=B0=E4=B9=8B?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E7=AD=89=E5=80=BC=E5=88=A4=E6=96=AD,?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E7=94=A8=3D=3D=E6=AF=94=E8=BE=83,=E5=8C=85=E8=A3=85?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E4=B8=8D=E8=83=BD=E7=94=A8?= =?UTF-8?q?equals=E6=9D=A5=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hutool-core/src/main/java/cn/hutool/core/img/Img.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 0d4b0bdab..c2d4fb67c 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 @@ -37,6 +37,7 @@ import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; +import java.math.BigDecimal; import java.net.URL; import java.nio.file.Path; @@ -302,7 +303,10 @@ public class Img implements Serializable { double heightRatio = NumberUtil.div(height, srcHeight); double widthRatio = NumberUtil.div(width, srcWidth); - if (widthRatio == heightRatio) { + // 浮点数之间的等值判断,基本数据类型不能用==比较,包装数据类型不能用equals来判断。 + BigDecimal heightRatioBigDecimal = new BigDecimal(heightRatio); + BigDecimal widthRatioBigDecimal = new BigDecimal(widthRatio); + if (heightRatioBigDecimal.compareTo(widthRatioBigDecimal) == 0) { // 长宽都按照相同比例缩放时,返回缩放后的图片 scale(width, height); } else if (widthRatio < heightRatio) {