This is an automated email from the ASF dual-hosted git repository.
anovikov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 3a374adfd9 IGNITE-21817 CriteriaException must keep error code for
mapping from SqlException. (#3449)
3a374adfd9 is described below
commit 3a374adfd9be83f397fff0f7a3de46d52e3c1abd
Author: Andrey Novikov <[email protected]>
AuthorDate: Fri Mar 22 11:19:33 2024 +0700
IGNITE-21817 CriteriaException must keep error code for mapping from
SqlException. (#3449)
---
.../table/criteria/CriteriaExceptionMapperUtil.java | 7 -------
.../table/criteria/CriteriaExceptionMapperUtilTest.java | 2 +-
.../ignite/internal/testframework/IgniteTestUtils.java | 2 +-
.../ignite/internal/table/ItCriteriaQueryTest.java | 17 +++++++++++------
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtil.java
b/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtil.java
index b9e1ec049f..e71a710ae2 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtil.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtil.java
@@ -22,7 +22,6 @@ import static
org.apache.ignite.lang.ErrorGroups.Common.INTERNAL_ERR;
import org.apache.ignite.lang.ErrorGroups.Common;
import org.apache.ignite.lang.TraceableException;
-import org.apache.ignite.sql.SqlException;
import org.apache.ignite.table.criteria.CriteriaException;
/**
@@ -36,8 +35,6 @@ public class CriteriaExceptionMapperUtil {
* <ul>
* <li>any instance of {@link Error} is returned as is, except {@link
AssertionError}
* that will always be mapped to {@link CriteriaException} with the
{@link Common#INTERNAL_ERR} error code.</li>
- * <li>any instance of {@link SqlException} is wrapped into {@link
CriteriaException} with the {@link Common#INTERNAL_ERR}
- * error code.</li>
* <li>any instance of {@link TraceableException} is wrapped into
{@link CriteriaException}
* with the original {@link TraceableException#traceId() traceUd}
and {@link TraceableException#code() code}.</li>
* <li>if there are no any mappers that can do a mapping from the
given error to a public exception,
@@ -57,10 +54,6 @@ public class CriteriaExceptionMapperUtil {
return e;
}
- if (e instanceof SqlException) {
- return new CriteriaException(INTERNAL_ERR, e);
- }
-
if (e instanceof TraceableException) {
TraceableException traceable = (TraceableException) e;
return new CriteriaException(traceable.traceId(),
traceable.code(), e.getMessage(), e);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtilTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtilTest.java
index 49a5dead8a..77b0db2047 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtilTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/table/criteria/CriteriaExceptionMapperUtilTest.java
@@ -63,7 +63,7 @@ class CriteriaExceptionMapperUtilTest {
CriteriaException mappedCriteriaErr = (CriteriaException) mappedErr;
assertThat("Mapped exception should have the same trace identifier.",
mappedCriteriaErr.traceId(), is(sqlErr.traceId()));
- assertThat("Mapped exception shouldn't have the same error code.",
mappedCriteriaErr.code(), is(INTERNAL_ERR));
+ assertThat("Mapped exception shouldn't have the same error code.",
mappedCriteriaErr.code(), is(sqlErr.code()));
}
/**
diff --git
a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
index 1b76ccef0f..8ab4055fdc 100644
---
a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
+++
b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
@@ -301,7 +301,7 @@ public final class IgniteTestUtils {
}
IgniteException igniteException = (IgniteException) throwable;
- assertEquals(expectedErrorCode, igniteException.code());
+ assertEquals(expectedErrorCode, igniteException.code(), "Invalid
error code: " + igniteException.codeAsString());
if (errorMessageFragment != null) {
assertThat(throwable.getMessage(),
containsString(errorMessageFragment));
diff --git
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItCriteriaQueryTest.java
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItCriteriaQueryTest.java
index c8a29a8aab..d907b38f26 100644
---
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItCriteriaQueryTest.java
+++
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItCriteriaQueryTest.java
@@ -22,10 +22,12 @@ import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
-import static
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows;
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrowsWithCode;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.await;
import static
org.apache.ignite.internal.testframework.matchers.TupleMatcher.tupleValue;
+import static org.apache.ignite.lang.ErrorGroups.Common.INTERNAL_ERR;
+import static org.apache.ignite.lang.ErrorGroups.Sql.STMT_VALIDATION_ERR;
+import static
org.apache.ignite.lang.ErrorGroups.Transactions.TX_ALREADY_FINISHED_ERR;
import static org.apache.ignite.lang.util.IgniteNameUtils.quote;
import static org.apache.ignite.table.criteria.Criteria.columnValue;
import static org.apache.ignite.table.criteria.Criteria.equalTo;
@@ -154,8 +156,9 @@ public class ItCriteriaQueryTest extends
ClusterPerClassIntegrationTest {
@ParameterizedTest
@MethodSource
public <T> void testRecordViewQuery(CriteriaQuerySource<T> view,
Function<T, Tuple> mapper) {
- assertThrows(
+ assertThrowsWithCode(
CriteriaException.class,
+ STMT_VALIDATION_ERR,
() -> view.query(null, columnValue("id", equalTo("2"))),
"Dynamic parameter requires adding explicit type cast"
);
@@ -259,8 +262,9 @@ public class ItCriteriaQueryTest extends
ClusterPerClassIntegrationTest {
@ParameterizedTest
@MethodSource
public <T> void testKeyValueView(CriteriaQuerySource<T> view, Function<T,
Entry<Tuple, Tuple>> mapper) {
- assertThrows(
+ assertThrowsWithCode(
CriteriaException.class,
+ STMT_VALIDATION_ERR,
() -> view.query(null, columnValue("id", equalTo("2"))),
"Dynamic parameter requires adding explicit type cast"
);
@@ -448,8 +452,8 @@ public class ItCriteriaQueryTest extends
ClusterPerClassIntegrationTest {
@ParameterizedTest
@MethodSource("allViews")
<T> void testInvalidColumnName(CriteriaQuerySource<T> view) {
- assertThrows(CriteriaException.class, () ->
await(view.queryAsync(null, columnValue("id1", equalTo(2)))),
- "Unexpected column name: ID1");
+ assertThrowsWithCode(CriteriaException.class, INTERNAL_ERR,
+ () -> await(view.queryAsync(null, columnValue("id1",
equalTo(2)))), "Unexpected column name: ID1");
}
private static Stream<Arguments> testRecordViewWithQuotes() {
@@ -532,8 +536,9 @@ public class ItCriteriaQueryTest extends
ClusterPerClassIntegrationTest {
public void testSessionClosing(CriteriaQuerySource<?> view, Transaction
tx) {
int baseSessionsCount = activeSessionsCount();
- assertThrows(
+ assertThrowsWithCode(
CriteriaException.class,
+ TX_ALREADY_FINISHED_ERR,
() -> view.query(tx, columnValue("id", equalTo(2))),
"Transaction is already finished"
);