修改了幂等性异常提示

This commit is contained in:
ajaxfan
2021-05-18 09:50:44 +08:00
parent 26cd94bcca
commit 33435e4ab8

View File

@ -64,8 +64,7 @@ public class IdempotentAspect {
} }
Idempotent idempotent = method.getAnnotation(Idempotent.class); Idempotent idempotent = method.getAnnotation(Idempotent.class);
/* key : url + 参数列表作为区分 */
/*key : url + 参数列表作为区分*/
String url = request.getRequestURL().toString(); String url = request.getRequestURL().toString();
String argString = JsonUtils.objectToJson(Arrays.asList(joinPoint.getArgs())); String argString = JsonUtils.objectToJson(Arrays.asList(joinPoint.getArgs()));
assert argString != null; assert argString != null;
@ -82,14 +81,13 @@ public class IdempotentAspect {
String value = LocalDateTime.now().toString().replace("T", " "); String value = LocalDateTime.now().toString().replace("T", " ");
if (null != rMapCache.get(key)) { if (null != rMapCache.get(key)) {
// had stored // had stored
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName(info,true); CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName(info, true);
} }
synchronized (this) { synchronized (this) {
boolean submitAble = redisTemplate.opsForValue().setIfAbsent(key, value,expireTime,timeUnit); boolean submitAble = redisTemplate.opsForValue().setIfAbsent(key, value, expireTime, timeUnit);
if (!submitAble) { if (!submitAble) {
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("[idempotent]:" + info,true); CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName(info, true);
} } else {
else {
log.info("[idempotent]:has stored key={},value={},expireTime={}{},now={}", key, value, expireTime, log.info("[idempotent]:has stored key={},value={},expireTime={}{},now={}", key, value, expireTime,
timeUnit, LocalDateTime.now().toString()); timeUnit, LocalDateTime.now().toString());
} }