From c57f1601a0029b0236341d535bb686c1851762ea Mon Sep 17 00:00:00 2001 From: da-daken <2844775971@qq.com> Date: Thu, 4 May 2023 20:01:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AD=98=E5=9C=A8=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../austin/service/api/impl/service/RecallServiceImpl.java | 6 ++++++ .../austin/service/api/impl/service/SendServiceImpl.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/RecallServiceImpl.java b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/RecallServiceImpl.java index 145a358..8e35331 100644 --- a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/RecallServiceImpl.java +++ b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/RecallServiceImpl.java @@ -1,5 +1,6 @@ package com.java3y.austin.service.api.impl.service; +import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.service.api.domain.SendRequest; import com.java3y.austin.service.api.domain.SendResponse; @@ -7,6 +8,7 @@ import com.java3y.austin.service.api.impl.domain.SendTaskModel; import com.java3y.austin.service.api.service.RecallService; import com.java3y.austin.support.pipeline.ProcessContext; import com.java3y.austin.support.pipeline.ProcessController; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,6 +26,10 @@ public class RecallServiceImpl implements RecallService { @Override public SendResponse recall(SendRequest sendRequest) { + // 添加对 sendRequest 参数的判空,防止后面空指针 + if(ObjectUtils.isEmpty(sendRequest)){ + return new SendResponse(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg()); + } SendTaskModel sendTaskModel = SendTaskModel.builder() .messageTemplateId(sendRequest.getMessageTemplateId()) .build(); diff --git a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/SendServiceImpl.java b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/SendServiceImpl.java index 5277384..75a55f2 100644 --- a/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/SendServiceImpl.java +++ b/austin-service-api-impl/src/main/java/com/java3y/austin/service/api/impl/service/SendServiceImpl.java @@ -1,6 +1,7 @@ package com.java3y.austin.service.api.impl.service; import cn.monitor4all.logRecord.annotation.OperationLog; +import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.vo.BasicResultVO; import com.java3y.austin.service.api.domain.BatchSendRequest; import com.java3y.austin.service.api.domain.SendRequest; @@ -9,6 +10,7 @@ import com.java3y.austin.service.api.impl.domain.SendTaskModel; import com.java3y.austin.service.api.service.SendService; import com.java3y.austin.support.pipeline.ProcessContext; import com.java3y.austin.support.pipeline.ProcessController; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,6 +30,10 @@ public class SendServiceImpl implements SendService { @Override @OperationLog(bizType = "SendService#send", bizId = "#sendRequest.messageTemplateId", msg = "#sendRequest") public SendResponse send(SendRequest sendRequest) { + // 添加对 sendRequest 参数的判空,防止后面空指针 + if(ObjectUtils.isEmpty(sendRequest)){ + return new SendResponse(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg()); + } SendTaskModel sendTaskModel = SendTaskModel.builder() .messageTemplateId(sendRequest.getMessageTemplateId()) From fc16666200a3dba62d99c093cd63459ef325a5bb Mon Sep 17 00:00:00 2001 From: da-daken <2844775971@qq.com> Date: Thu, 4 May 2023 20:02:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?opt=EF=BC=9A=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E5=88=A4=E7=A9=BA=E7=94=A8=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/java3y/austin/support/utils/ContentHolderUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/austin-support/src/main/java/com/java3y/austin/support/utils/ContentHolderUtil.java b/austin-support/src/main/java/com/java3y/austin/support/utils/ContentHolderUtil.java index ae3f868..3d0b7b5 100644 --- a/austin-support/src/main/java/com/java3y/austin/support/utils/ContentHolderUtil.java +++ b/austin-support/src/main/java/com/java3y/austin/support/utils/ContentHolderUtil.java @@ -1,5 +1,6 @@ package com.java3y.austin.support.utils; +import org.apache.commons.lang3.StringUtils; import org.springframework.context.expression.MapAccessor; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.util.PropertyPlaceholderHelper; @@ -54,7 +55,7 @@ public class ContentHolderUtil { @Override public String resolvePlaceholder(String placeholderName) { String value = paramMap.get(placeholderName); - if (null == value) { + if (StringUtils.isEmpty(value)) { String errorStr = MessageFormat.format("template:{0} require param:{1},but not exist! paramMap:{2}", template, placeholderName, paramMap.toString()); throw new IllegalArgumentException(errorStr);