Aias00 commented on code in PR #7259:
URL: https://github.com/apache/shenyu/pull/7259#discussion_r4111192125
##########
shenyu-register-center/shenyu-register-client/shenyu-register-client-api/src/main/java/org/apache/shenyu/register/client/api/FailbackRegistryRepository.java:
##########
@@ -202,6 +201,30 @@ public void accept(final String key) {
if (Objects.isNull(holder)) {
return;
}
+ persist(holder);
+ }
+
+ /**
+ * Retry a pending registration without removing failures queued during
the attempt.
+ *
+ * @param key the registration key
+ */
+ public void retry(final String key) {
+ Holder holder = concurrentHashMap.remove(key);
+ if (Objects.isNull(holder)) {
+ return;
+ }
+ try {
+ persist(holder);
+ } catch (RuntimeException ex) {
+ // A newer failure has its own timer task; otherwise retain this
task's retry.
+ if (Objects.isNull(concurrentHashMap.putIfAbsent(key, holder))) {
Review Comment:
Non-blocking: this is the line that makes the rescheduling decision, and
both branches are correct - `null` means this task reclaimed the key so the
throw re-arms the wheel, non-null means a newer failure already owns it and
added its own timer task, so swallowing is right.
Two follow-on notes:
- `accept` and `remove` are no longer called by the framework
(`FailureRegistryTask` was the only production caller, and it now calls
`retry`). Keeping them for compatibility is fine, but any caller that still
does `accept(key)` followed by `remove(key)` - including custom retry tasks
outside this repo - keeps the #6558 lost-failure bug. Worth a sentence in the
release note.
- `addToFail` still drops the newer `Holder` when one is already pending,
because `putIfAbsent` returns the existing entry and `t` is discarded.
Pre-existing and low impact (the key encodes the registration), but it is now
the only remaining "newest wins" gap - a comment would stop someone
rediscovering it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]