style: 规范化项目(五):解决45处代码编译警告

pull/69/head
xiaoxiamo 3 months ago
parent b819f37690
commit 452dffb6b8

@ -37,7 +37,7 @@ public class CronAsyncThreadPoolConfig {
return ExecutorBuilder.create()
.setCorePoolSize(ThreadPoolConstant.COMMON_CORE_POOL_SIZE)
.setMaxPoolSize(ThreadPoolConstant.COMMON_MAX_POOL_SIZE)
.setWorkQueue(new LinkedBlockingQueue(ThreadPoolConstant.BIG_QUEUE_SIZE))
.setWorkQueue(new LinkedBlockingQueue<>(ThreadPoolConstant.BIG_QUEUE_SIZE))
.setHandler(new ThreadPoolExecutor.CallerRunsPolicy())
.setAllowCoreThreadTimeOut(true)
.setKeepAliveTime(ThreadPoolConstant.SMALL_KEEP_LIVE_TIME, TimeUnit.SECONDS)

@ -42,7 +42,7 @@ public class CrowdBatchTaskPending extends AbstractLazyPending<CrowdInfoVo> {
public CrowdBatchTaskPending() {
PendingParam<CrowdInfoVo> pendingParam = new PendingParam<>();
pendingParam.setQueue(new LinkedBlockingQueue(PendingConstant.QUEUE_SIZE))
pendingParam.setQueue(new LinkedBlockingQueue<>(PendingConstant.QUEUE_SIZE))
.setTimeThreshold(PendingConstant.TIME_THRESHOLD)
.setNumThreshold(AustinConstant.BATCH_RECEIVER_SIZE)
.setExecutorService(CronAsyncThreadPoolConfig.getConsumePendingThreadPool());

@ -10,7 +10,6 @@ import com.java3y.austin.cron.csv.CountFileRowHandler;
import com.java3y.austin.cron.vo.CrowdInfoVo;
import lombok.extern.slf4j.Slf4j;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
@ -60,7 +59,7 @@ public class ReadFileUtils {
// 把首行当做是标题获取reader
try (CsvReader reader = CsvUtil.getReader(
new InputStreamReader(new FileInputStream(path), CharsetUtil.CHARSET_UTF_8),
new InputStreamReader(Files.newInputStream(Paths.get(path)), CharsetUtil.CHARSET_UTF_8),
new CsvReadConfig().setContainsHeader(true))) {
reader.read(countFileRowHandler);

@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.common.base.Throwables;
import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO;
@ -48,7 +49,7 @@ public class CronTaskServiceImpl implements CronTaskService {
@Override
public BasicResultVO saveCronTask(XxlJobInfo xxlJobInfo) {
Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobInfo), Map.class);
Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobInfo), new TypeReference<Map<String, Object>>() {});
String path = Objects.isNull(xxlJobInfo.getId()) ? xxlAddresses + XxlJobConstant.INSERT_URL
: xxlAddresses + XxlJobConstant.UPDATE_URL;
@ -174,7 +175,7 @@ public class CronTaskServiceImpl implements CronTaskService {
@Override
public BasicResultVO createGroup(XxlJobGroup xxlJobGroup) {
Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobGroup), Map.class);
Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobGroup), new TypeReference<Map<String, Object>>() {});
String path = xxlAddresses + XxlJobConstant.JOB_GROUP_INSERT_URL;
HttpResponse response;

@ -37,7 +37,7 @@ public class SlideWindowLimitService extends AbstractLimitService {
@PostConstruct
public void init() {
redisScript = new DefaultRedisScript();
redisScript = new DefaultRedisScript<>();
redisScript.setResultType(Long.class);
redisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("limit.lua")));
}

@ -128,7 +128,7 @@ public class DingDingRobotHandler extends BaseHandler{
Mac mac = Mac.getInstance(CommonConstant.HMAC_SHA256_ENCRYPTION_ALGO);
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), CommonConstant.HMAC_SHA256_ENCRYPTION_ALGO));
byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData), CommonConstant.CHARSET_UTF_8));
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData), StandardCharsets.UTF_8), CommonConstant.CHARSET_UTF_8);
} catch (Exception e) {
log.error("DingDingHandler#assembleSign fail!:{}", Throwables.getStackTraceAsString(e));
}

@ -45,7 +45,7 @@ public class EmailHandler extends BaseHandler{
channelCode = ChannelType.EMAIL.getCode();
// 按照请求限流,默认单机 3 qps 具体数值配置在apollo动态调整)
Double rateInitValue = Double.valueOf(3);
double rateInitValue = 3.0;
flowControlParam = FlowControlParam.builder().rateInitValue(rateInitValue)
.rateLimitStrategy(RateLimitStrategy.REQUEST_RATE_LIMIT)
.rateLimiter(RateLimiter.create(rateInitValue)).build();
@ -61,7 +61,7 @@ public class EmailHandler extends BaseHandler{
if (CollUtil.isEmpty(files)) {
MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true);
} else {
MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true, files.toArray(new File[files.size()]));
MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true, files.toArray(new File[0]));
}

@ -45,9 +45,9 @@ public class SmsHandler extends BaseHandler{
private static final String FLOW_KEY = "msgTypeSmsConfig";
private static final String FLOW_KEY_PREFIX = "message_type_";
/**
*
*
*/
private static final SecureRandom secureRandom = new SecureRandom();
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
@Autowired
private SmsRecordDao smsRecordDao;
@ -104,10 +104,10 @@ public class SmsHandler extends BaseHandler{
}
// 生成一个随机数[1,total],看落到哪个区间
int index = secureRandom.nextInt(total) + 1;
int index = SECURE_RANDOM.nextInt(total) + 1;
MessageTypeSmsConfig supplier = null;
MessageTypeSmsConfig supplierBack = null;
MessageTypeSmsConfig supplier;
MessageTypeSmsConfig supplierBack;
for (int i = 0; i < messageTypeSmsConfigs.size(); ++i) {
if (index <= messageTypeSmsConfigs.get(i).getWeights()) {
supplier = messageTypeSmsConfigs.get(i);

@ -13,7 +13,7 @@ import org.apache.flink.util.Collector;
public class AustinFlatMapFunction implements FlatMapFunction<String, AnchorInfo> {
@Override
public void flatMap(String value, Collector<AnchorInfo> collector) throws Exception {
public void flatMap(String value, Collector<AnchorInfo> collector){
AnchorInfo anchorInfo = JSON.parseObject(value, AnchorInfo.class);
collector.collect(anchorInfo);
}

@ -28,7 +28,7 @@ import java.util.List;
public class AustinSink implements SinkFunction<AnchorInfo> {
@Override
public void invoke(AnchorInfo anchorInfo, Context context) throws Exception {
public void invoke(AnchorInfo anchorInfo, Context context){
realTimeData(anchorInfo);
}

@ -48,7 +48,7 @@ public class LettuceRedisUtils {
commands.flushCommands();
LettuceFutures.awaitAll(10, TimeUnit.SECONDS,
futures.toArray(new RedisFuture[futures.size()]));
futures.toArray(new RedisFuture[0]));
connect.close();
}

@ -26,7 +26,7 @@ public class SupportThreadPoolConfig {
return ExecutorBuilder.create()
.setCorePoolSize(ThreadPoolConstant.SINGLE_CORE_POOL_SIZE)
.setMaxPoolSize(ThreadPoolConstant.SINGLE_MAX_POOL_SIZE)
.setWorkQueue(new LinkedBlockingQueue(ThreadPoolConstant.BIG_QUEUE_SIZE))
.setWorkQueue(new LinkedBlockingQueue<>(ThreadPoolConstant.BIG_QUEUE_SIZE))
.setHandler(new ThreadPoolExecutor.CallerRunsPolicy())
.setAllowCoreThreadTimeOut(true)
.setKeepAliveTime(ThreadPoolConstant.SMALL_KEEP_LIVE_TIME, TimeUnit.SECONDS)

@ -23,7 +23,7 @@ public class ConfigServiceImpl implements ConfigService {
*
*/
private static final String PROPERTIES_PATH = "local.properties";
private final Props props = new Props(PROPERTIES_PATH, StandardCharsets.UTF_8);
private final Props PROPS = new Props(PROPERTIES_PATH, StandardCharsets.UTF_8);
/**
* apollo
@ -49,7 +49,7 @@ public class ConfigServiceImpl implements ConfigService {
} else if (Boolean.TRUE.equals(enableNacos)) {
return nacosUtils.getProperty(key, defaultValue);
} else {
return props.getProperty(key, defaultValue);
return PROPS.getProperty(key, defaultValue);
}
}
}

@ -45,7 +45,7 @@ public class ContentHolderUtil {
@Override
public String resolvePlaceholder(String placeholderName) {
if (Objects.isNull(paramMap)) {
String errorStr = MessageFormat.format("template:{0} require param:{1},but not exist! paramMap:{2}", template, placeholderName, paramMap);
String errorStr = MessageFormat.format("template:{0} require param:{1},but not exist! paramMap:{2}", template, placeholderName, null);
throw new IllegalArgumentException(errorStr);
}
String value = paramMap.get(placeholderName);

@ -31,7 +31,7 @@ public class LogUtils extends CustomLogListener {
* @OperationLog
*/
@Override
public void createLog(LogDTO logDTO) throws Exception {
public void createLog(LogDTO logDTO){
log.info(JSON.toJSONString(logDTO));
}

@ -177,7 +177,7 @@ public class OkHttpUtils {
private String execute(Request request) {
try (Response response = okHttpClient.newCall(request).execute()) {
if (response.isSuccessful()) {
return response.body().string();
return String.valueOf(response.body());
}
} catch (Exception e) {
log.error(Throwables.getStackTraceAsString(e));

@ -171,14 +171,15 @@ public class RedisUtils {
*/
public Boolean execLimitLua(RedisScript<Long> redisScript, List<String> keys, String... args) {
// 可变参数转数组
String[] argsArray = args != null ? args : new String[0];
try {
Long execute = redisTemplate.execute(redisScript, keys, args);
Long execute = redisTemplate.execute(redisScript, keys, (Object[]) argsArray);
if (Objects.isNull(execute)) {
return false;
}
return CommonConstant.TRUE.equals(execute.intValue());
} catch (Exception e) {
log.error("redis execLimitLua fail! e:{}", Throwables.getStackTraceAsString(e));
}
return false;

@ -34,7 +34,7 @@ public class AustinApplication implements CommandLineRunner {
}
@Override
public void run(String... args) throws Exception {
public void run(String... args) {
log.info(AnsiOutput.toString(AustinConstant.PROJECT_BANNER, "\n", AnsiColor.GREEN, AustinConstant.PROJECT_NAME, AnsiColor.DEFAULT, AnsiStyle.FAINT));
log.info("Austin start succeeded, Index >> http://127.0.0.1:{}/", serverPort);
log.info("Austin start succeeded, Swagger Url >> http://127.0.0.1:{}/swagger-ui/index.html", serverPort);

@ -60,7 +60,7 @@ public class AlipayMiniProgramController {
AlipayOpenMiniMessageTemplateBatchqueryModel model = new AlipayOpenMiniMessageTemplateBatchqueryModel();
// 设置子板状态列表
List<String> statusList = new ArrayList<String>();
List<String> statusList = new ArrayList<>();
statusList.add("STARTED");
model.setStatusList(statusList);
@ -112,7 +112,7 @@ public class AlipayMiniProgramController {
AlipayOpenMiniMessageTemplateBatchqueryModel model = new AlipayOpenMiniMessageTemplateBatchqueryModel();
// 设置子板状态列表
List<String> statusList = new ArrayList<String>();
List<String> statusList = new ArrayList<>();
statusList.add("STARTED");
model.setStatusList(statusList);

@ -5,6 +5,7 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.common.base.Throwables;
import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO;
@ -137,7 +138,7 @@ public class MessageTemplateController {
@ApiOperation("/测试发送接口")
public SendResponse test(@RequestBody MessageTemplateParam messageTemplateParam) {
Map<String, String> variables = JSON.parseObject(messageTemplateParam.getMsgContent(), Map.class);
Map<String, String> variables = JSON.parseObject(messageTemplateParam.getMsgContent(), new TypeReference<Map<String, String>>() {});
MessageParam messageParam = MessageParam.builder().receiver(messageTemplateParam.getReceiver()).variables(variables).build();
SendRequest sendRequest = SendRequest.builder().code(BusinessCode.COMMON_SEND.getCode()).messageTemplateId(messageTemplateParam.getId()).messageParam(messageParam).build();
SendResponse response = sendService.send(sendRequest);

@ -35,7 +35,7 @@ public class ExceptionHandlerAdvice {
@ResponseStatus(HttpStatus.OK)
public BasicResultVO<RespStatusEnum> commonResponse(CommonException ce) {
log.error(Throwables.getStackTrace(ce));
return new BasicResultVO(ce.getCode(), ce.getMessage(), ce.getRespStatusEnum());
return new BasicResultVO<>(ce.getCode(), ce.getMessage(), ce.getRespStatusEnum());
}
}

@ -465,11 +465,11 @@ public class Convert4Amis {
itemsVO.setBusinessId(String.valueOf(smsRecord.getMessageTemplateId()));
itemsVO.setContent(smsRecord.getMsgContent());
itemsVO.setSendType(EnumUtil.getDescriptionByCode(smsRecord.getStatus(), SmsStatus.class));
itemsVO.setSendTime(DateUtil.format(new Date(Long.valueOf(smsRecord.getCreated() * 1000L)), DatePattern.NORM_DATETIME_PATTERN));
itemsVO.setSendTime(DateUtil.format(new Date(smsRecord.getCreated() * 1000L), DatePattern.NORM_DATETIME_PATTERN));
} else {
itemsVO.setReceiveType(EnumUtil.getDescriptionByCode(smsRecord.getStatus(), SmsStatus.class));
itemsVO.setReceiveContent(smsRecord.getReportContent());
itemsVO.setReceiveTime(DateUtil.format(new Date(Long.valueOf(smsRecord.getUpdated() * 1000L)), DatePattern.NORM_DATETIME_PATTERN));
itemsVO.setReceiveTime(DateUtil.format(new Date(smsRecord.getUpdated() * 1000L), DatePattern.NORM_DATETIME_PATTERN));
}
}
itemsVoS.add(itemsVO);

@ -4,9 +4,9 @@ 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.nio.file.Files;
/**
@ -27,13 +27,13 @@ public class SpringFileUtils {
public static File getFile(MultipartFile multipartFile) {
String fileName = multipartFile.getOriginalFilename();
File file = new File(fileName);
try (OutputStream out = new FileOutputStream(file)){
try (OutputStream out = Files.newOutputStream(file.toPath())){
byte[] ss = multipartFile.getBytes();
for (int i = 0; i < ss.length; i++) {
out.write(ss[i]);
for (byte s : ss) {
out.write(s);
}
} catch (IOException e) {
log.error("SpringFileUtils#getFile multipartFile is converted to File error:{}", e);
log.error("SpringFileUtils#getFile multipartFile is converted to File error:{}", e.toString());
return null;
}
return file;

Loading…
Cancel
Save