修复FindBugs bug

This commit is contained in:
lsy
2017-10-03 20:52:23 +08:00
parent 732dc175b1
commit 0c81710cd4
5 changed files with 7 additions and 6 deletions
@@ -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();
@@ -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 <text.length() ; i++) {
String s = String.valueOf(text.charAt(i));
if (s.getBytes().length>1){
if (s.getBytes("utf-8").length>1){
textWidth++;
}else{
textWidth +=0.5F;
@@ -13,4 +13,4 @@ import org.springframework.context.annotation.Configuration;
@ComponentScan(basePackages = {"com.micro.fast.common.config"})
public class CommonApplication {
}
}
@@ -78,7 +78,7 @@ public class ServerResponse<T> {
*/
@JsonIgnore //使其不再json序列化结果之中
public boolean isSuccess() {
return Const.ServerResponseCode.SUCCESS.getCode() == this.code;
return Const.ServerResponseCode.SUCCESS.getCode().intValue() == this.code;
}
//请求成功
@@ -13,4 +13,4 @@ public class UcenterApplicationTests {
public void contextLoads() {
}
}
}