This is an automated email from the ASF dual-hosted git repository.
mpochatkin 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 e1aee4a1c8b IGNITE-26586 Fix case-sensitive field mapping (#6687)
e1aee4a1c8b is described below
commit e1aee4a1c8b5d2b1106da3c3c4e4c9c07de6a9c3
Author: Mikhail <[email protected]>
AuthorDate: Wed Oct 8 15:27:54 2025 +0300
IGNITE-26586 Fix case-sensitive field mapping (#6687)
---
.../apache/ignite/lang/MarshallerException.java | 9 ++
.../apache/ignite/table/mapper/MapperBuilder.java | 19 ++--
.../ignite/internal/marshaller/Marshaller.java | 19 ++--
.../app/client/ItThinClientMarshallingTest.java | 10 +-
...mbeddedTest.java => ItTablePutGetBaseTest.java} | 81 +++++++++++++--
.../internal/table/ItTablePutGetEmbeddedTest.java | 115 +--------------------
.../internal/table/ItTablePutGetThinTest.java | 2 +-
.../marshaller/asm/AsmMarshallerGenerator.java | 2 +-
.../asm/ObjectMarshallerCodeGenerator.java | 7 +-
.../schema/marshaller/KvMarshallerTest.java | 6 +-
.../schema/marshaller/RecordMarshallerTest.java | 4 +-
.../RecordMarshallerValidationsTest.java | 2 +-
.../sql/engine/ItPkOnlyTableCrossApiTest.java | 3 +-
13 files changed, 123 insertions(+), 156 deletions(-)
diff --git
a/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java
b/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java
index af14e61fccc..7c1f366fc61 100644
--- a/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java
+++ b/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java
@@ -26,6 +26,15 @@ import org.jetbrains.annotations.Nullable;
* The failure can be due to a value not matching the a schema or to another
reason.
*/
public class MarshallerException extends IgniteException {
+ /**
+ * Creates a new exception with the given error message.
+ *
+ * @param msg Error message.
+ */
+ public MarshallerException(String msg) {
+ super(Marshalling.COMMON_ERR, msg);
+ }
+
/**
* Creates a new exception with the given error message.
*
diff --git
a/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
b/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
index 0f00ebda986..4f1d164f272 100644
---
a/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
+++
b/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
@@ -17,6 +17,8 @@
package org.apache.ignite.table.mapper;
+import static org.apache.ignite.lang.util.IgniteNameUtils.parseIdentifier;
+
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.AbstractMap.SimpleEntry;
@@ -26,7 +28,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import org.apache.ignite.catalog.annotations.Column;
-import org.apache.ignite.lang.util.IgniteNameUtils;
/**
* Mapper builder provides methods for mapping object fields to columns.
@@ -170,7 +171,7 @@ public final class MapperBuilder<T> {
public MapperBuilder<T> map(String fieldName, String columnName, String...
fieldColumnPairs) {
ensureNotStale();
- String colName0 = IgniteNameUtils.parseIdentifier(columnName);
+ String colName0 = parseIdentifier(columnName);
if (columnToFields == null) {
throw new IllegalArgumentException("Natively supported types
doesn't support field mapping.");
@@ -182,7 +183,7 @@ public final class MapperBuilder<T> {
for (int i = 0; i < fieldColumnPairs.length; i += 2) {
if (columnToFields.put(
-
IgniteNameUtils.parseIdentifier(Objects.requireNonNull(fieldColumnPairs[i +
1])),
+ parseIdentifier(Objects.requireNonNull(fieldColumnPairs[i
+ 1])),
requireValidField(fieldColumnPairs[i])) != null
) {
throw new IllegalArgumentException("Mapping for a column
already exists: " + colName0);
@@ -229,7 +230,7 @@ public final class MapperBuilder<T> {
public <ObjectT, ColumnT> MapperBuilder<T> convert(String columnName,
TypeConverter<ObjectT, ColumnT> converter) {
ensureNotStale();
- if (columnConverters.put(IgniteNameUtils.parseIdentifier(columnName),
converter) != null) {
+ if (columnConverters.put(parseIdentifier(columnName), converter) !=
null) {
throw new IllegalArgumentException("Column converter already
exists: " + columnName);
}
@@ -279,7 +280,7 @@ public final class MapperBuilder<T> {
.map(MapperBuilder::getColumnToFieldMapping)
.filter(entry -> !fields.contains(entry.getValue()))
// Ignore manually mapped fields/columns.
- .forEach(entry ->
mapping.putIfAbsent(entry.getKey().toUpperCase(), entry.getValue()));
+ .forEach(entry -> mapping.putIfAbsent(entry.getKey(),
entry.getValue()));
}
return new PojoMapperImpl<>(targetType, mapping, columnConverters);
@@ -288,11 +289,7 @@ public final class MapperBuilder<T> {
private static SimpleEntry<String, String> getColumnToFieldMapping(Field
fld) {
String fldName = fld.getName();
var column = fld.getAnnotation(Column.class);
- if (column == null) {
- return new SimpleEntry<>(fldName, fldName);
- } else {
- var columnName = column.value().isEmpty() ? fldName :
column.value();
- return new SimpleEntry<>(columnName, fldName);
- }
+ var columnName = column != null && !column.value().isEmpty() ?
column.value() : fldName;
+ return new SimpleEntry<>(parseIdentifier(columnName), fldName);
}
}
diff --git
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
index 488c1b410df..d19d027977a 100644
---
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
+++
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.marshaller;
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
import static
org.apache.ignite.internal.marshaller.FieldAccessor.createIdentityAccessor;
import java.util.Collection;
@@ -56,7 +57,7 @@ public abstract class Marshaller {
}
if (mapper.targetType().isPrimitive()) {
- throw new IllegalArgumentException("Mappers for primitive types
are not supported: " + mapper.targetType());
+ throw new MarshallerException(format("Mappers for primitive types
are not supported: {}", mapper.targetType()));
}
if (mapper instanceof OneColumnMapper) {
@@ -64,7 +65,7 @@ public abstract class Marshaller {
} else if (mapper instanceof PojoMapper) {
return pojoMarshaller(cols, (PojoMapper<?>) mapper,
requireAllFields, allowUnmappedFields);
} else {
- throw new IllegalArgumentException("Mapper of unsupported type: "
+ mapper.getClass());
+ throw new MarshallerException(format("Mapper of unsupported type:
{}", mapper.getClass()));
}
}
@@ -84,8 +85,8 @@ public abstract class Marshaller {
private static MarshallerColumn findColumnIndex(MarshallerColumn[] cols,
@Nullable String name) {
if (name == null) {
if (cols.length != 1) {
- throw new IllegalArgumentException(String.format(
- "Failed to map object to a single column: schema
contains %d columns but no mapped columns were provided",
+ throw new MarshallerException(format(
+ "Failed to map object to a single column: schema
contains {} columns but no mapped columns were provided",
cols.length
));
}
@@ -99,8 +100,8 @@ public abstract class Marshaller {
}
}
- throw new IllegalArgumentException(String.format(
- "Failed to map object to a single column: mappedColumn '%s' is
not present in the schema",
+ throw new MarshallerException(format(
+ "Failed to map object to a single column: mappedColumn '{}' is
not present in the schema",
name
));
}
@@ -131,7 +132,7 @@ public abstract class Marshaller {
if (fieldName == null) {
if (requireAllFields) {
- throw new IllegalArgumentException(String.format("No
mapped object field found for column '%s'", columnName));
+ throw new MarshallerException(format("No mapped object
field found for column '{}'", columnName));
}
fieldAccessors[i] = FieldAccessor.noopAccessor(col);
@@ -158,8 +159,8 @@ public abstract class Marshaller {
fieldSet.remove(fieldName);
}
- throw new IllegalArgumentException(
- String.format("Fields %s of type %s are not mapped to
columns", fieldSet, mapper.targetType().getName()),
+ throw new MarshallerException(
+ format("Fields {} of type {} are not mapped to
columns", fieldSet, mapper.targetType().getName()),
new UnmappedColumnsException()
);
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientMarshallingTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientMarshallingTest.java
index bd190794867..0f440378272 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientMarshallingTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientMarshallingTest.java
@@ -55,7 +55,7 @@ public class ItThinClientMarshallingTest extends
ItAbstractThinClientTest {
pojo.val = "val";
pojo.unmapped = "unmapped";
- Throwable ex = assertThrowsWithCause(() -> pojoView.upsert(null,
pojo), IllegalArgumentException.class);
+ Throwable ex = assertThrowsWithCause(() -> pojoView.upsert(null,
pojo), MarshallerException.class);
assertEquals(
"Fields [unmapped, unmapped2] of type "
+
"org.apache.ignite.internal.runner.app.client.ItThinClientMarshallingTest$TestPojo2
are not mapped to columns",
@@ -69,7 +69,7 @@ public class ItThinClientMarshallingTest extends
ItAbstractThinClientTest {
var pojo = new TestPojo();
- Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, pojo,
pojo), IllegalArgumentException.class);
+ Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, pojo,
pojo), MarshallerException.class);
assertEquals(
"Fields [val] of type
org.apache.ignite.internal.runner.app.client.ItAbstractThinClientTest$TestPojo "
+ "are not mapped to columns",
@@ -83,7 +83,7 @@ public class ItThinClientMarshallingTest extends
ItAbstractThinClientTest {
var pojo = new TestPojo();
- Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, 1,
pojo), IllegalArgumentException.class);
+ Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, 1,
pojo), MarshallerException.class);
assertEquals(
"Fields [key] of type
org.apache.ignite.internal.runner.app.client.ItAbstractThinClientTest$TestPojo "
+ "are not mapped to columns",
@@ -129,7 +129,7 @@ public class ItThinClientMarshallingTest extends
ItAbstractThinClientTest {
Table table = ignite().tables().table(TABLE_NAME);
var pojoView = table.recordView(MissingFieldPojo.class);
- Throwable ex = assertThrowsWithCause(() -> pojoView.upsert(null, new
MissingFieldPojo()), IllegalArgumentException.class);
+ Throwable ex = assertThrowsWithCause(() -> pojoView.upsert(null, new
MissingFieldPojo()), MarshallerException.class);
assertEquals("No mapped object field found for column 'KEY'",
ex.getMessage());
}
@@ -138,7 +138,7 @@ public class ItThinClientMarshallingTest extends
ItAbstractThinClientTest {
Table table = ignite().tables().table(TABLE_NAME);
var kvPojoView = table.keyValueView(MissingFieldPojo.class,
String.class);
- Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, new
MissingFieldPojo(), ""), IllegalArgumentException.class);
+ Throwable ex = assertThrowsWithCause(() -> kvPojoView.put(null, new
MissingFieldPojo(), ""), MarshallerException.class);
assertEquals("No mapped object field found for column 'KEY'",
ex.getMessage());
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetBaseTest.java
similarity index 68%
copy from
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
copy to
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetBaseTest.java
index 5a071d85c7e..b9afc168387 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetBaseTest.java
@@ -17,11 +17,20 @@
package org.apache.ignite.internal.table;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import java.util.Objects;
import java.util.stream.Stream;
+import org.apache.ignite.catalog.annotations.Column;
import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
+import org.apache.ignite.internal.tostring.S;
+import org.apache.ignite.lang.Cursor;
+import org.apache.ignite.lang.MarshallerException;
import org.apache.ignite.lang.NullableValue;
import org.apache.ignite.table.IgniteTables;
import org.apache.ignite.table.KeyValueView;
@@ -34,9 +43,12 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
/**
- * Tests to check that rows can be inserted and retrieved through embedded
client.
+ * Base tests to check that rows can be inserted.
*/
-public class ItTablePutGetEmbeddedTest extends ClusterPerClassIntegrationTest {
+public abstract class ItTablePutGetBaseTest extends
ClusterPerClassIntegrationTest {
+
+ abstract IgniteTables tables();
+
@AfterEach
void dropTables() {
dropAllTables();
@@ -122,6 +134,67 @@ public class ItTablePutGetEmbeddedTest extends
ClusterPerClassIntegrationTest {
assertNull(res2.get());
}
+ @Test
+ public void testCaseSensitiveMapping() {
+ sql("CREATE TABLE sampleTable (\"lowercase\" varchar(255), id int
primary key)");
+
+ RecordView<PojoExample> sampleTable =
tables().table("sampleTable").recordView(PojoExample.class);
+
+ PojoExample pojoExample = new PojoExample();
+ pojoExample.id = 1;
+ pojoExample.lowercase = "test";
+
+ sampleTable.upsert(null, pojoExample);
+
+ try (Cursor<PojoExample> cursor = sampleTable.query(null, null)) {
+ assertThat(cursor.hasNext(), is(true));
+ assertThat(cursor.next(), equalTo(pojoExample));
+ }
+
+ RecordView<PojoExampleIncorrect> sampleTableIncorrect =
tables().table("sampleTable").recordView(PojoExampleIncorrect.class);
+
+ PojoExampleIncorrect pojoExampleIncorrect = new PojoExampleIncorrect();
+ pojoExampleIncorrect.id = 1;
+ pojoExampleIncorrect.lowercase = "test";
+
+ assertThrows(MarshallerException.class, () ->
sampleTableIncorrect.upsert(null, pojoExampleIncorrect));
+ }
+
+ static class PojoExampleIncorrect {
+ int id;
+
+ String lowercase;
+ }
+
+ static class PojoExample {
+ int id;
+
+ @Column("\"lowercase\"")
+ String lowercase;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof PojoExample)) {
+ return false;
+ }
+ PojoExample that = (PojoExample) o;
+ return id == that.id && Objects.equals(lowercase, that.lowercase);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, lowercase);
+ }
+
+ @Override
+ public String toString() {
+ return S.toString(this);
+ }
+ }
+
private static Stream<Arguments> tableDefinitions() {
return Stream.of(
"CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,
c3)) COLOCATE BY (c1)",
@@ -134,8 +207,4 @@ public class ItTablePutGetEmbeddedTest extends
ClusterPerClassIntegrationTest {
"CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c3,
c1)) COLOCATE BY (c3, c1)"
).map(Arguments::of);
}
-
- IgniteTables tables() {
- return CLUSTER.aliveNode().tables();
- }
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
index 5a071d85c7e..688addab40b 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetEmbeddedTest.java
@@ -17,124 +17,13 @@
package org.apache.ignite.internal.table;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.stream.Stream;
-import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
-import org.apache.ignite.lang.NullableValue;
import org.apache.ignite.table.IgniteTables;
-import org.apache.ignite.table.KeyValueView;
-import org.apache.ignite.table.RecordView;
-import org.apache.ignite.table.Tuple;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
/**
* Tests to check that rows can be inserted and retrieved through embedded
client.
*/
-public class ItTablePutGetEmbeddedTest extends ClusterPerClassIntegrationTest {
- @AfterEach
- void dropTables() {
- dropAllTables();
- }
-
- @ParameterizedTest
- @MethodSource("tableDefinitions")
- @SuppressWarnings("DataFlowIssue")
- void putGetInTableWithDifferentOrdersOfColumnsInKeyAndColocationKey(String
tableDefinitionDdl) {
- sql(tableDefinitionDdl);
-
- {
- KeyValueView<Tuple, Tuple> kvView =
tables().table("test").keyValueView();
-
- for (int i = 0; i < 10; i++) {
- Tuple key = Tuple.create()
- .set("c1", i)
- .set("c3", i * 100);
-
- Tuple val = Tuple.create()
- .set("c2", i * 10);
-
- kvView.put(null, key, val);
- }
-
- for (int i = 0; i < 10; i++) {
- Tuple key = Tuple.create()
- .set("c1", i)
- .set("c3", i * 100);
-
- assertEquals(i * 10, kvView.get(null, key).intValue("c2"));
- assertEquals(i * 10, kvView.get(null, key).intValue(0));
- }
- }
-
- {
- RecordView<Tuple> recordView = tables().table("test").recordView();
-
- for (int i = 100; i < 110; i++) {
- Tuple record = Tuple.create()
- .set("c1", i)
- .set("c2", i * 10)
- .set("c3", i * 100);
-
- recordView.insert(null, record);
- }
-
- for (int i = 100; i < 110; i++) {
- Tuple key = Tuple.create()
- .set("c1", i)
- .set("c3", i * 100);
-
- assertEquals(i * 10, recordView.get(null, key).intValue("c2"));
- assertEquals(i * 10, recordView.get(null, key).intValue(1));
- }
- }
- }
-
- @Test
- public void testSingleColumnTableKeyValueView() {
- String tableName = "TEST_TABLE_1";
-
- sql("CREATE TABLE " + tableName + " (id int primary key)");
- sql("INSERT INTO " + tableName + " (id) VALUES (1)");
-
- // Tuples.
- KeyValueView<Tuple, Tuple> kvTupleView =
tables().table(tableName).keyValueView();
- Tuple key = Tuple.create().set("id", 1);
- Tuple val = Tuple.create();
-
- kvTupleView.put(null, key, val);
- Tuple res = kvTupleView.get(null, key);
-
- assertEquals(val, res);
-
- // Classes.
- KeyValueView<Integer, Void> kvPrimitiveView =
tables().table(tableName).keyValueView(Integer.class, Void.class);
- int key2 = 2;
-
- kvPrimitiveView.put(null, key2, null);
- NullableValue<Void> res2 = kvPrimitiveView.getNullable(null, key2);
-
- assertNull(res2.get());
- }
-
- private static Stream<Arguments> tableDefinitions() {
- return Stream.of(
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,
c3)) COLOCATE BY (c1)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,
c3)) COLOCATE BY (c3)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,
c3)) COLOCATE BY (c1, c3)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c1,
c3)) COLOCATE BY (c3, c1)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c3,
c1)) COLOCATE BY (c1)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c3,
c1)) COLOCATE BY (c3)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c3,
c1)) COLOCATE BY (c1, c3)",
- "CREATE TABLE test (c1 INT, c2 INT, c3 INT, PRIMARY KEY (c3,
c1)) COLOCATE BY (c3, c1)"
- ).map(Arguments::of);
- }
-
+public class ItTablePutGetEmbeddedTest extends ItTablePutGetBaseTest {
+ @Override
IgniteTables tables() {
return CLUSTER.aliveNode().tables();
}
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetThinTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetThinTest.java
index bc325c28116..c44bc2eb908 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetThinTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTablePutGetThinTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeAll;
/**
* Tests to check that rows can be inserted and retrieved through thin client.
*/
-public class ItTablePutGetThinTest extends ItTablePutGetEmbeddedTest {
+public class ItTablePutGetThinTest extends ItTablePutGetBaseTest {
private static IgniteClient client;
@BeforeAll
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
index 09da3238eab..0f73e721dcc 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
@@ -131,7 +131,7 @@ public class AsmMarshallerGenerator implements
MarshallerFactory {
MarshallerUtil.factoryForClass(valClass));
} catch (LinkageError | NoSuchMethodException | InstantiationException
| IllegalAccessException | InvocationTargetException e) {
- throw new IllegalArgumentException("Failed to create marshaller
for key-value pair: schemaVer=" + schema.version()
+ throw new MarshallerException("Failed to create marshaller for
key-value pair: schemaVer=" + schema.version()
+ ", keyClass=" + keyClass.getSimpleName() + ",
valueClass=" + valClass.getSimpleName(), e);
}
}
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
index b3932c26aab..db7e7b3c1d2 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
@@ -40,6 +40,7 @@ import java.util.stream.Collectors;
import org.apache.ignite.internal.marshaller.BinaryMode;
import org.apache.ignite.internal.marshaller.MarshallerColumn;
import org.apache.ignite.internal.schema.row.RowAssembler;
+import org.apache.ignite.lang.MarshallerException;
import org.apache.ignite.table.mapper.PojoMapper;
/**
@@ -70,7 +71,7 @@ class ObjectMarshallerCodeGenerator implements
MarshallerCodeGenerator {
Field field = mapper.targetType().getDeclaredField(fldName);
flds.put(fldName.toUpperCase(), field);
} catch (NoSuchFieldException e) {
- throw new IllegalArgumentException(
+ throw new MarshallerException(
"Field " + fldName + " is returned from mapper of type
" + mapper.getClass().getName()
+ ", but is not present in target class " +
mapper.targetType().getName(), e);
}
@@ -83,7 +84,7 @@ class ObjectMarshallerCodeGenerator implements
MarshallerCodeGenerator {
var fldNames =
flds.values().stream().map(Field::getName).sorted().collect(Collectors.toList());
- throw new IllegalArgumentException(
+ throw new MarshallerException(
"Fields " + fldNames + " of type " + targetClass.getName()
+ " are not mapped to columns");
}
@@ -93,7 +94,7 @@ class ObjectMarshallerCodeGenerator implements
MarshallerCodeGenerator {
Field field = flds.get(column.name());
if (field == null) {
- throw new IllegalArgumentException("No field found for column
" + column.name());
+ throw new MarshallerException("No field found for column " +
column.name());
}
validateColumnType(column, field.getType());
diff --git
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
index cb6552a903c..ebbab334c6d 100644
---
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
+++
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
@@ -260,8 +260,8 @@ public class KvMarshallerTest {
valueColumns
);
- IllegalArgumentException ex = assertThrows(
- IllegalArgumentException.class,
+ MarshallerException ex = assertThrows(
+ MarshallerException.class,
() -> factory.create(schema, Integer.class,
TestObjectWithAllTypes.class)
);
@@ -355,7 +355,7 @@ public class KvMarshallerTest {
SchemaDescriptor schema = new
SchemaDescriptor(schemaVersion.incrementAndGet(), keyCols, valCols);
- assertThrows(IllegalArgumentException.class, () ->
factory.create(schema, TestKeyObject.class, TestObjectWithAllTypes.class));
+ assertThrows(MarshallerException.class, () -> factory.create(schema,
TestKeyObject.class, TestObjectWithAllTypes.class));
}
@ParameterizedTest
diff --git
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
index 080375c4e90..821bbaa8e3a 100644
---
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
+++
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
@@ -156,8 +156,8 @@ public class RecordMarshallerTest {
}
);
- IllegalArgumentException ex = assertThrows(
- IllegalArgumentException.class,
+ MarshallerException ex = assertThrows(
+ MarshallerException.class,
() -> factory.create(schema, TestObjectWithAllTypes.class));
assertEquals(
diff --git
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
index 6517eae94c7..0d7f8259bdb 100644
---
a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
+++
b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
@@ -152,7 +152,7 @@ public class RecordMarshallerValidationsTest {
assertThrowsWithCause(
() -> factory.create(schema, TestK2V1.class),
- IllegalArgumentException.class,
+ MarshallerException.class,
"No mapped object field found for column 'K1'");
}
diff --git
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
index 61ddbf76735..3a4032aaa2d 100644
---
a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
+++
b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItPkOnlyTableCrossApiTest.java
@@ -37,6 +37,7 @@ import java.util.function.Consumer;
import org.apache.ignite.internal.sql.BaseSqlIntegrationTest;
import org.apache.ignite.internal.tx.InternalTransaction;
import org.apache.ignite.lang.IgniteException;
+import org.apache.ignite.lang.MarshallerException;
import org.apache.ignite.lang.NullableValue;
import org.apache.ignite.lang.UnexpectedNullValueException;
import org.apache.ignite.table.KeyValueView;
@@ -156,7 +157,7 @@ public class ItPkOnlyTableCrossApiTest extends
BaseSqlIntegrationTest {
rwTx -> {
IgniteException ex = assertThrows(IgniteException.class,
() -> tab.keyValueView(KeyObject.class,
Integer.class).put(rwTx, key, 1));
- assertThat(ex.getCause().getCause(),
is(instanceOf(IllegalArgumentException.class)));
+ assertThat(ex.getCause().getCause(),
is(instanceOf(MarshallerException.class)));
kvView.put(rwTx, key, null);