From 0c81710cd4035054b4f264c010c9328005590134 Mon Sep 17 00:00:00 2001 From: lsy <18332763730@163.com> Date: Tue, 3 Oct 2017 20:52:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFindBugs=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/micro/fast/util/AESUtil.java | 2 +- .../src/main/java/com/micro/fast/util/WatermarkerUtil.java | 5 +++-- .../main/java/com/micro/fast/common/CommonApplication.java | 2 +- .../java/com/micro/fast/common/response/ServerResponse.java | 2 +- .../java/com/micro/fast/ucenter/UcenterApplicationTests.java | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/boot-starter-util/src/main/java/com/micro/fast/util/AESUtil.java b/boot-starter-util/src/main/java/com/micro/fast/util/AESUtil.java index 0dbb40b..bf299b5 100644 --- a/boot-starter-util/src/main/java/com/micro/fast/util/AESUtil.java +++ b/boot-starter-util/src/main/java/com/micro/fast/util/AESUtil.java @@ -88,7 +88,7 @@ public class AESUtil { //2.根据encodeRules规则初始化密钥生成器 //生成一个128位的随机数,根据传入的字节数组 SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); - secureRandom.setSeed(encodeRules.getBytes()); + secureRandom.setSeed(encodeRules.getBytes("utf-8")); keyGenerator.init(128,secureRandom); //3.产生原始对称密钥 SecretKey original_secretKey = keyGenerator.generateKey(); diff --git a/boot-starter-util/src/main/java/com/micro/fast/util/WatermarkerUtil.java b/boot-starter-util/src/main/java/com/micro/fast/util/WatermarkerUtil.java index 67690ed..5ff7659 100644 --- a/boot-starter-util/src/main/java/com/micro/fast/util/WatermarkerUtil.java +++ b/boot-starter-util/src/main/java/com/micro/fast/util/WatermarkerUtil.java @@ -9,6 +9,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.UUID; /** @@ -109,12 +110,12 @@ public class WatermarkerUtil { * @param text 要输入的文本 * @return  转换成中文的宽度单位px */ - public int getTextLength(String text){ + public int getTextLength(String text) throws UnsupportedEncodingException { float textWidth = 0.0F; //1.计算等同于多少个中文字符 for (int i = 0; i 1){ + if (s.getBytes("utf-8").length>1){ textWidth++; }else{ textWidth +=0.5F; diff --git a/common/src/main/java/com/micro/fast/common/CommonApplication.java b/common/src/main/java/com/micro/fast/common/CommonApplication.java index 543af02..fbfc9d2 100644 --- a/common/src/main/java/com/micro/fast/common/CommonApplication.java +++ b/common/src/main/java/com/micro/fast/common/CommonApplication.java @@ -13,4 +13,4 @@ import org.springframework.context.annotation.Configuration; @ComponentScan(basePackages = {"com.micro.fast.common.config"}) public class CommonApplication { -} +} \ No newline at end of file diff --git a/common/src/main/java/com/micro/fast/common/response/ServerResponse.java b/common/src/main/java/com/micro/fast/common/response/ServerResponse.java index 50fe1f6..ccec743 100644 --- a/common/src/main/java/com/micro/fast/common/response/ServerResponse.java +++ b/common/src/main/java/com/micro/fast/common/response/ServerResponse.java @@ -78,7 +78,7 @@ public class ServerResponse { */ @JsonIgnore //使其不再json序列化结果之中 public boolean isSuccess() { - return Const.ServerResponseCode.SUCCESS.getCode() == this.code; + return Const.ServerResponseCode.SUCCESS.getCode().intValue() == this.code; } //请求成功 diff --git a/ucenter/src/test/java/com/micro/fast/ucenter/UcenterApplicationTests.java b/ucenter/src/test/java/com/micro/fast/ucenter/UcenterApplicationTests.java index 1b4cc43..525b9cf 100644 --- a/ucenter/src/test/java/com/micro/fast/ucenter/UcenterApplicationTests.java +++ b/ucenter/src/test/java/com/micro/fast/ucenter/UcenterApplicationTests.java @@ -13,4 +13,4 @@ public class UcenterApplicationTests { public void contextLoads() { } -} +} \ No newline at end of file