You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Ravil Galeyev <rg...@gmail.com> on 2020/05/31 13:46:49 UTC

[IGNITE-12633] [Question] Purpose of creating a new instance of QueryCancelledException every time?

Hello Igniters,

I've started working on IGNITE-12633
<https://issues.apache.org/jira/browse/IGNITE-12633>

If I understand the goal of the ticket right, QueryCancelledException
needs a constructor that accepts a cause exception.
@iseliverstov please, correct me if I'm wrong.

As the first step, I looked at `QueryCancelledException` usages and
found an interesting thing.

When an exception is cought, we check the cause
`if (X.cause(e, QueryCancelledException.class) != null)`

If the cause is QueryCancelledException, we throw or return a new
instance of QueryCancelledException: `return exceptionToResult(new
QueryCancelledException());`.
It happens i.e. in JdbcRequestHandler.java#L504
<https://github.com/apache/ignite/blob/master/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java#L504>

I'd like to know what the purpose of creating a new instance instead
of reusing the existing one?
`X.cause(e, T.class)` returns either null or T.

Therefore, we can write
```
QueryCancelledException cause = X.cause(e, QueryCancelledException.class);
if (cause != null) return exceptionToResult(cause);
```

I did it in my branch hereJdbcRequestHandler.java#L504
<https://github.com/dehasi/ignite/blob/IGNITE-12633-add-query-cancel-purpose/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java#L504>
In this way, we won't lose the cause of QueryCancelledException.

What I'm misunderstanding?

Best regards,
Ravil