feat: 2.1.0
1. 优化javax校验器 2. 修复JacksonSerializerNPE问题
This commit is contained in:
parent
5380104724
commit
52f3785b52
@ -1,14 +1,17 @@
|
|||||||
package com.aizuda.easy.retry.client.core.serializer;
|
package com.aizuda.easy.retry.client.core.serializer;
|
||||||
|
|
||||||
import com.aizuda.easy.retry.client.core.RetryArgSerializer;
|
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.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jackson序列化
|
* Jackson序列化
|
||||||
@ -17,6 +20,7 @@ import java.lang.reflect.Type;
|
|||||||
* @date : 2022-03-07 15:08
|
* @date : 2022-03-07 15:08
|
||||||
*/
|
*/
|
||||||
@Component("easyRetryJacksonSerializer")
|
@Component("easyRetryJacksonSerializer")
|
||||||
|
@Slf4j
|
||||||
public class JacksonSerializer implements RetryArgSerializer {
|
public class JacksonSerializer implements RetryArgSerializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,8 +37,16 @@ public class JacksonSerializer implements RetryArgSerializer {
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
JsonNode jsonNode = JsonUtil.toJson(infoStr);
|
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++) {
|
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;
|
return params;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.aizuda.easy.retry.client.model;
|
package com.aizuda.easy.retry.client.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.aizuda.easy.retry.client.model;
|
package com.aizuda.easy.retry.client.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成idempotentId模型
|
* 生成idempotentId模型
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.aizuda.easy.retry.client.model;
|
package com.aizuda.easy.retry.client.model;
|
||||||
|
|
||||||
import lombok.Data;
|
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;
|
private String idempotentId;
|
||||||
@NotBlank(message = "executorName 不能为空")
|
@NotBlank(message = "executorName 不能为空")
|
||||||
private String executorName;
|
private String executorName;
|
||||||
@NotBlank(message = "retryStatus 不能为空")
|
@NotNull(message = "retryStatus 不能为空")
|
||||||
private Integer retryStatus;
|
private Integer retryStatus;
|
||||||
@NotBlank(message = "uniqueId 不能为空")
|
@NotBlank(message = "uniqueId 不能为空")
|
||||||
private String uniqueId;
|
private String uniqueId;
|
||||||
|
@ -115,12 +115,6 @@ public class ExecCallbackUnitActor extends AbstractActor {
|
|||||||
retryCallbackDTO.setExecutorName(retryTask.getExecutorName());
|
retryCallbackDTO.setExecutorName(retryTask.getExecutorName());
|
||||||
retryCallbackDTO.setUniqueId(retryTask.getUniqueId());
|
retryCallbackDTO.setUniqueId(retryTask.getUniqueId());
|
||||||
|
|
||||||
// HttpEntity<RetryCallbackDTO> 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.<RpcClient, Result>newBuilder()
|
RpcClient rpcClient = RequestBuilder.<RpcClient, Result>newBuilder()
|
||||||
.hostPort(serverNode.getHostPort())
|
.hostPort(serverNode.getHostPort())
|
||||||
.groupName(serverNode.getGroupName())
|
.groupName(serverNode.getGroupName())
|
||||||
|
Loading…
Reference in New Issue
Block a user