| Line 63... |
Line 63... |
| 63 |
String idemKey = (String) request.getAttribute(REQUEST_ATTR_IDEM_KEY);
|
63 |
String idemKey = (String) request.getAttribute(REQUEST_ATTR_IDEM_KEY);
|
| 64 |
if (idemKey == null) {
|
64 |
if (idemKey == null) {
|
| 65 |
return;
|
65 |
return;
|
| 66 |
}
|
66 |
}
|
| 67 |
String redisKey = IDEM_PREFIX + idemKey;
|
67 |
String redisKey = IDEM_PREFIX + idemKey;
|
| 68 |
if (ex == null && response.getStatus() >= 200 && response.getStatus() < 300) {
|
68 |
// On error, release the claim immediately so the caller can retry without waiting.
|
| - |
|
69 |
// On success, leave the key untouched: keep its original claim-time TTL (set in
|
| 69 |
redisTemplate.opsForValue().set(redisKey, "done", IDEM_TTL_SECONDS, TimeUnit.SECONDS);
|
70 |
// preHandle) and do NOT re-set it. Re-setting refreshed the TTL on every completion,
|
| - |
|
71 |
// sliding the dedupe window forward and falsely rejecting later legitimate submissions.
|
| 70 |
} else {
|
72 |
if (ex != null || response.getStatus() < 200 || response.getStatus() >= 300) {
|
| 71 |
redisTemplate.delete(redisKey);
|
73 |
redisTemplate.delete(redisKey);
|
| 72 |
}
|
74 |
}
|
| 73 |
}
|
75 |
}
|
| 74 |
|
76 |
|
| 75 |
private String buildIdempotencyKey(HttpServletRequest request, String header) {
|
77 |
private String buildIdempotencyKey(HttpServletRequest request, String header) {
|