From 4be4e3c9f22004883e84f5aba7c11b71b1c3d4a0 Mon Sep 17 00:00:00 2001 From: xiaoxiamo <82970607@qq.com> Date: Thu, 11 Jul 2024 18:56:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SpotBugs=E6=89=AB=E6=8F=8F=E5=88=86?= =?UTF-8?q?=E6=9E=90=EF=BC=88=E4=BA=94=EF=BC=89=EF=BC=9A=E5=86=85=E9=83=A8?= =?UTF-8?q?=E7=B1=BB=E6=94=B9=E4=B8=BAstatic=E7=B1=BB=E5=9E=8B=E3=80=81par?= =?UTF-8?q?seXXX=E6=9B=BF=E6=8D=A2valueOf()(=E6=95=88=E7=8E=87=E6=9B=B4?= =?UTF-8?q?=E9=AB=98)=E3=80=81=E9=9D=99=E6=80=81=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E9=9B=86=E5=90=88=E6=94=B9=E4=B8=BA=E4=B8=8D=E5=8F=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=81=E5=87=8F=E5=B0=91=E6=8B=86=E7=AE=B1=E8=A3=85?= =?UTF-8?q?=E7=AE=B1=E6=93=8D=E4=BD=9C=E3=80=81=E4=BC=98=E9=9B=85=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../austin/cron/xxl/utils/XxlJobUtils.java | 2 +- .../handler/domain/sms/LinTongSendResult.java | 2 +- .../impl/action/send/SendAfterCheckAction.java | 9 ++++++--- .../austin/stream/utils/LettuceRedisUtils.java | 2 +- .../austin/web/utils/SpringFileUtils.java | 18 +++++------------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/austin-cron/src/main/java/com/java3y/austin/cron/xxl/utils/XxlJobUtils.java b/austin-cron/src/main/java/com/java3y/austin/cron/xxl/utils/XxlJobUtils.java index f10bf8d..77d984b 100644 --- a/austin-cron/src/main/java/com/java3y/austin/cron/xxl/utils/XxlJobUtils.java +++ b/austin-cron/src/main/java/com/java3y/austin/cron/xxl/utils/XxlJobUtils.java @@ -84,7 +84,7 @@ public class XxlJobUtils { if (Objects.isNull(basicResultVO.getData())) { XxlJobGroup xxlJobGroup = XxlJobGroup.builder().appname(appName).title(jobHandlerName).addressType(CommonConstant.FALSE).build(); if (RespStatusEnum.SUCCESS.getCode().equals(cronTaskService.createGroup(xxlJobGroup).getStatus())) { - return (int) cronTaskService.getGroupId(appName, jobHandlerName).getData(); + return (Integer) cronTaskService.getGroupId(appName, jobHandlerName).getData(); } } return basicResultVO.getData(); diff --git a/austin-handler/src/main/java/com/java3y/austin/handler/domain/sms/LinTongSendResult.java b/austin-handler/src/main/java/com/java3y/austin/handler/domain/sms/LinTongSendResult.java index 8229f57..27d682d 100644 --- a/austin-handler/src/main/java/com/java3y/austin/handler/domain/sms/LinTongSendResult.java +++ b/austin-handler/src/main/java/com/java3y/austin/handler/domain/sms/LinTongSendResult.java @@ -32,7 +32,7 @@ public class LinTongSendResult { @Data @AllArgsConstructor @NoArgsConstructor - public class DataDTO { + public static class DataDTO { Integer code; String message; Long msgId; diff --git a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/action/send/SendAfterCheckAction.java b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/action/send/SendAfterCheckAction.java index b6da121..9213a7c 100644 --- a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/action/send/SendAfterCheckAction.java +++ b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/action/send/SendAfterCheckAction.java @@ -31,11 +31,14 @@ public class SendAfterCheckAction implements BusinessProcess { /** * 邮件和手机号正则 */ - protected static final Map CHANNEL_REGEX_EXP = new HashMap<>(); + protected static final Map CHANNEL_REGEX_EXP; static { - CHANNEL_REGEX_EXP.put(IdType.PHONE.getCode(), PHONE_REGEX_EXP); - CHANNEL_REGEX_EXP.put(IdType.EMAIL.getCode(), EMAIL_REGEX_EXP); + Map tempMap = new HashMap<>(); + tempMap.put(IdType.PHONE.getCode(), PHONE_REGEX_EXP); + tempMap.put(IdType.EMAIL.getCode(), EMAIL_REGEX_EXP); + // 初始化为不可变集合,避免被恶意修改 + CHANNEL_REGEX_EXP = Collections.unmodifiableMap(tempMap); } diff --git a/austin-stream/src/main/java/com/java3y/austin/stream/utils/LettuceRedisUtils.java b/austin-stream/src/main/java/com/java3y/austin/stream/utils/LettuceRedisUtils.java index 0639839..f156909 100644 --- a/austin-stream/src/main/java/com/java3y/austin/stream/utils/LettuceRedisUtils.java +++ b/austin-stream/src/main/java/com/java3y/austin/stream/utils/LettuceRedisUtils.java @@ -27,7 +27,7 @@ public class LettuceRedisUtils { static { RedisURI redisUri = RedisURI.Builder.redis(AustinFlinkConstant.REDIS_IP) - .withPort(Integer.valueOf(AustinFlinkConstant.REDIS_PORT)) + .withPort(Integer.parseInt(AustinFlinkConstant.REDIS_PORT)) .withPassword(AustinFlinkConstant.REDIS_PASSWORD.toCharArray()) .build(); redisClient = RedisClient.create(redisUri); diff --git a/austin-web/src/main/java/com/java3y/austin/web/utils/SpringFileUtils.java b/austin-web/src/main/java/com/java3y/austin/web/utils/SpringFileUtils.java index 8af9482..021845a 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/utils/SpringFileUtils.java +++ b/austin-web/src/main/java/com/java3y/austin/web/utils/SpringFileUtils.java @@ -1,18 +1,19 @@ package com.java3y.austin.web.utils; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.Objects; /** * @author 3y * multipartFile 转成 File 对象 */ +@Slf4j public class SpringFileUtils { private SpringFileUtils() { } @@ -26,23 +27,14 @@ public class SpringFileUtils { public static File getFile(MultipartFile multipartFile) { String fileName = multipartFile.getOriginalFilename(); File file = new File(fileName); - OutputStream out = null; - try { - out = new FileOutputStream(file); + try (OutputStream out = new FileOutputStream(file)){ byte[] ss = multipartFile.getBytes(); for (int i = 0; i < ss.length; i++) { out.write(ss[i]); } } catch (IOException e) { - e.printStackTrace(); - } finally { - if (Objects.nonNull(out)) { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + log.error("SpringFileUtils#getFile multipartFile is converted to File error:{}", e); + return null; } return file; }