You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexander Lapin (Jira)" <ji...@apache.org> on 2021/09/23 18:18:00 UTC
[jira] [Updated] (IGNITE-15581) Proper business-logic exception
propagation from raft listener to client code
[ https://issues.apache.org/jira/browse/IGNITE-15581?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Lapin updated IGNITE-15581:
-------------------------------------
Description:
*Problem.*
In case of business logic exceptions thrown from within raft listeners it's recommended to use
{code:java}
clo.result(throwable)
{code}
Such throwable is propagated to raft client in ActionResponse container and later on competes client future in common but not an exceptional way (which is a problem):
{code:java}
return fut.thenApply(resp -> (R) resp.result());
{code}
{code:java}
@Override public <R> CompletableFuture<R> run(Command cmd) {
Peer leader = this.leader;
if (leader == null)
return refreshLeader().thenCompose(res -> run(cmd));
ActionRequest req = factory.actionRequest().command(cmd).groupId(groupId).readOnlySafe(true).build();
CompletableFuture<ActionResponse> fut = new CompletableFuture<>();
sendWithRetry(leader, req, currentTimeMillis() + timeout, fut);
return fut.thenApply(resp -> (R) resp.result());
}
{code}
Client future usually have some specific generic type, for example CompletableFuture<Void>, that doesn't match an exception, so client future is completed exceptionally with ClassCastException with the cause of initial server side throwable.
was:
*Problem.*
In case of business logic exceptions thrown from within raft listeners it's recommended to use
{code:java}
clo.result(throwable)
{code}
Such throwable is propagated to raft client in ActionResponse container and later on competes future with common but not exceptional way (which is a problem):
{code:java}
return fut.thenApply(resp -> (R) resp.result());
{code}
{code:java}
@Override public <R> CompletableFuture<R> run(Command cmd) {
Peer leader = this.leader;
if (leader == null)
return refreshLeader().thenCompose(res -> run(cmd));
ActionRequest req = factory.actionRequest().command(cmd).groupId(groupId).readOnlySafe(true).build();
CompletableFuture<ActionResponse> fut = new CompletableFuture<>();
sendWithRetry(leader, req, currentTimeMillis() + timeout, fut);
return fut.thenApply(resp -> (R) resp.result());
}
{code}
Client future usually have some specific generic type, for example CompletableFuture<Void> that doesn't match an exception, so client future is completed exceptionally with ClassCastException with the root reason of initial server side throwable.
> Proper business-logic exception propagation from raft listener to client code
> -----------------------------------------------------------------------------
>
> Key: IGNITE-15581
> URL: https://issues.apache.org/jira/browse/IGNITE-15581
> Project: Ignite
> Issue Type: Improvement
> Reporter: Alexander Lapin
> Priority: Major
> Labels: ignite-3
>
> *Problem.*
> In case of business logic exceptions thrown from within raft listeners it's recommended to use
> {code:java}
> clo.result(throwable)
> {code}
> Such throwable is propagated to raft client in ActionResponse container and later on competes client future in common but not an exceptional way (which is a problem):
> {code:java}
> return fut.thenApply(resp -> (R) resp.result());
> {code}
> {code:java}
> @Override public <R> CompletableFuture<R> run(Command cmd) {
> Peer leader = this.leader;
> if (leader == null)
> return refreshLeader().thenCompose(res -> run(cmd));
> ActionRequest req = factory.actionRequest().command(cmd).groupId(groupId).readOnlySafe(true).build();
> CompletableFuture<ActionResponse> fut = new CompletableFuture<>();
> sendWithRetry(leader, req, currentTimeMillis() + timeout, fut);
> return fut.thenApply(resp -> (R) resp.result());
> }
> {code}
> Client future usually have some specific generic type, for example CompletableFuture<Void>, that doesn't match an exception, so client future is completed exceptionally with ClassCastException with the cause of initial server side throwable.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)