From 52f3785b52460dc280d971203863a634a2b229cf Mon Sep 17 00:00:00 2001 From: byteblogs168 <598092184@qq.com> Date: Wed, 19 Jul 2023 17:45:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=202.1.0=201.=20=E4=BC=98=E5=8C=96javax?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=99=A8=202.=20=E4=BF=AE=E5=A4=8DJacksonSer?= =?UTF-8?q?ializerNPE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/core/serializer/JacksonSerializer.java | 14 +++++++++++++- .../easy/retry/client/model/DispatchRetryDTO.java | 2 +- .../client/model/GenerateRetryIdempotentIdDTO.java | 3 ++- .../easy/retry/client/model/RetryCallbackDTO.java | 6 ++++-- .../dispatch/actor/exec/ExecCallbackUnitActor.java | 6 ------ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/serializer/JacksonSerializer.java b/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/serializer/JacksonSerializer.java index 71b5c6b9..e82f151c 100644 --- a/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/serializer/JacksonSerializer.java +++ b/easy-retry-client-core/src/main/java/com/aizuda/easy/retry/client/core/serializer/JacksonSerializer.java @@ -1,14 +1,17 @@ package com.aizuda.easy.retry.client.core.serializer; import com.aizuda.easy.retry.client.core.RetryArgSerializer; +import com.aizuda.easy.retry.common.core.log.LogUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.aizuda.easy.retry.common.core.util.JsonUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.util.Objects; /** * Jackson序列化 @@ -17,6 +20,7 @@ import java.lang.reflect.Type; * @date : 2022-03-07 15:08 */ @Component("easyRetryJacksonSerializer") +@Slf4j public class JacksonSerializer implements RetryArgSerializer { @Override @@ -33,8 +37,16 @@ public class JacksonSerializer implements RetryArgSerializer { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = JsonUtil.toJson(infoStr); + if (Objects.isNull(jsonNode)) { + LogUtils.warn(log, "jsonNode is null. infoStr:[{}]", infoStr); + return params; + } + for (int i = 0; i < paramTypes.length; i++) { - params[i] = mapper.readValue(jsonNode.get(i).toString(), mapper.constructType(paramTypes[i])); + JsonNode node = jsonNode.get(i); + if (Objects.nonNull(node)) { + params[i] = mapper.readValue(node.toString(), mapper.constructType(paramTypes[i])); + } } return params; diff --git a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/DispatchRetryDTO.java b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/DispatchRetryDTO.java index 5bd7bb8e..5c930f42 100644 --- a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/DispatchRetryDTO.java +++ b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/DispatchRetryDTO.java @@ -1,8 +1,8 @@ package com.aizuda.easy.retry.client.model; import lombok.Data; -import org.hibernate.validator.constraints.NotBlank; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** diff --git a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/GenerateRetryIdempotentIdDTO.java b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/GenerateRetryIdempotentIdDTO.java index d45a9060..9bcd1bef 100644 --- a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/GenerateRetryIdempotentIdDTO.java +++ b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/GenerateRetryIdempotentIdDTO.java @@ -1,7 +1,8 @@ package com.aizuda.easy.retry.client.model; import lombok.Data; -import org.hibernate.validator.constraints.NotBlank; + +import javax.validation.constraints.NotBlank; /** * 生成idempotentId模型 diff --git a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/RetryCallbackDTO.java b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/RetryCallbackDTO.java index 6abd28c4..28e7c389 100644 --- a/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/RetryCallbackDTO.java +++ b/easy-retry-common/easy-retry-common-client-api/src/main/java/com/aizuda/easy/retry/client/model/RetryCallbackDTO.java @@ -1,7 +1,9 @@ package com.aizuda.easy.retry.client.model; import lombok.Data; -import org.hibernate.validator.constraints.NotBlank; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; /** * 服务端调度重试入参 @@ -21,7 +23,7 @@ public class RetryCallbackDTO { private String idempotentId; @NotBlank(message = "executorName 不能为空") private String executorName; - @NotBlank(message = "retryStatus 不能为空") + @NotNull(message = "retryStatus 不能为空") private Integer retryStatus; @NotBlank(message = "uniqueId 不能为空") private String uniqueId; diff --git a/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/support/dispatch/actor/exec/ExecCallbackUnitActor.java b/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/support/dispatch/actor/exec/ExecCallbackUnitActor.java index 5259dd2d..2f58f497 100644 --- a/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/support/dispatch/actor/exec/ExecCallbackUnitActor.java +++ b/easy-retry-server/src/main/java/com/aizuda/easy/retry/server/support/dispatch/actor/exec/ExecCallbackUnitActor.java @@ -115,12 +115,6 @@ public class ExecCallbackUnitActor extends AbstractActor { retryCallbackDTO.setExecutorName(retryTask.getExecutorName()); retryCallbackDTO.setUniqueId(retryTask.getUniqueId()); -// HttpEntity requestEntity = new HttpEntity<>(retryCallbackDTO); -// -// String format = MessageFormat.format(URL, serverNode.getHostIp(), serverNode.getHostPort().toString(), serverNode.getContextPath()); -// Result result = restTemplate.postForObject(format, requestEntity, Result.class); - - RpcClient rpcClient = RequestBuilder.newBuilder() .hostPort(serverNode.getHostPort()) .groupName(serverNode.getGroupName())