-
-
Notifications
You must be signed in to change notification settings - Fork 17
GH-1052 Fix ignore calling synchronous events in async code #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,45 +29,46 @@ public CompletableFuture<Boolean> isIgnored(UUID requester, UUID target) { | |||||
} | ||||||
|
||||||
@Override | ||||||
public CompletableFuture<Boolean> ignore(UUID requester, UUID target) { | ||||||
public void ignore(UUID requester, UUID target) { | ||||||
IgnoreEvent event = this.caller.callEvent(new IgnoreEvent(requester, target)); | ||||||
|
||||||
if (event.isCancelled()) { | ||||||
return CompletableFuture.completedFuture(false); | ||||||
return; | ||||||
} | ||||||
|
||||||
return this.ignoreRepository.ignore(requester, target).thenApply(unused -> true); | ||||||
this.ignoreRepository.ignore(requester, target); | ||||||
CitralFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
@Override | ||||||
public CompletableFuture<Boolean> ignoreAll(UUID requester) { | ||||||
public void ignoreAll(UUID requester) { | ||||||
IgnoreAllEvent event = this.caller.callEvent(new IgnoreAllEvent(requester)); | ||||||
|
||||||
if (event.isCancelled()) { | ||||||
return CompletableFuture.completedFuture(false); | ||||||
return; | ||||||
} | ||||||
|
||||||
return this.ignoreRepository.ignoreAll(requester).thenApply(unused -> true); | ||||||
this.ignoreRepository.ignoreAll(requester).thenApply(unused -> true); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary operation that does nothing The - this.ignoreRepository.ignoreAll(requester).thenApply(unused -> true);
+ this.ignoreRepository.ignoreAll(requester); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added error handling from commons in this space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CitralFlo Thanks for the clarification! I understand you've added error handling from commons in this space. I notice that this line uses // Other methods use:
this.ignoreRepository.ignore(requester, target).thenApply(unused -> FutureHandler.whenSuccess(null));
// But ignoreAll currently uses:
this.ignoreRepository.ignoreAll(requester).thenApply(unused -> true); Would you like me to update my suggestion to align with the error handling pattern used in the other methods? 🐰 🧠 Learnings used
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caution CodeRabbit plans did not produce any file changes. |
||||||
} | ||||||
|
||||||
@Override | ||||||
public CompletableFuture<Boolean> unIgnore(UUID requester, UUID target) { | ||||||
public void unIgnore(UUID requester, UUID target) { | ||||||
UnIgnoreEvent event = this.caller.callEvent(new UnIgnoreEvent(requester, target)); | ||||||
|
||||||
if (event.isCancelled()) { | ||||||
return CompletableFuture.completedFuture(false); | ||||||
return; | ||||||
} | ||||||
return this.ignoreRepository.unIgnore(requester, target).thenApply(unused -> true); | ||||||
|
||||||
this.ignoreRepository.unIgnore(requester, target).thenApply(unused -> true); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public CompletableFuture<Boolean> unIgnoreAll(UUID requester) { | ||||||
public void unIgnoreAll(UUID requester) { | ||||||
UnIgnoreAllEvent event = this.caller.callEvent(new UnIgnoreAllEvent(requester)); | ||||||
|
||||||
if (event.isCancelled()) { | ||||||
return CompletableFuture.completedFuture(false); | ||||||
return; | ||||||
} | ||||||
return this.ignoreRepository.unIgnoreAll(requester).thenApply(unused -> true); | ||||||
} | ||||||
|
||||||
this.ignoreRepository.unIgnoreAll(requester).thenApply(unused -> true); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Inconsistent execution pattern
The
ignoreAll
method calls the service directly whileignore
uses the scheduler. This creates an inconsistent pattern - both should use the same approach for predictability.📝 Committable suggestion
🤖 Prompt for AI Agents