This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-15754
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit b0e54fa07d35482b81f7c7298889f96580427471
Author: Andrew Mashenkov <[email protected]>
AuthorDate: Fri Oct 22 11:09:38 2021 +0300

    Fix marshaller exception handling.
---
 .../internal/schema/marshaller/MarshallerUtil.java |   3 +-
 .../ignite/internal/schema/row/RowAssembler.java   |  67 +++++++----
 .../schema/marshaller/TupleMarshaller.java         |  10 +-
 ...rshaller.java => TupleMarshallerException.java} |  36 ++----
 .../marshaller}/TupleMarshallerImpl.java           | 125 ++++++++++++---------
 .../internal/table/KeyValueBinaryViewImpl.java     |  59 +++++-----
 .../internal/table/RecordBinaryViewImpl.java       |  55 +++++----
 .../TupleMarshallerFixlenOnlyBenchmark.java        |   5 +-
 .../TupleMarshallerVarlenOnlyBenchmark.java        |   5 +-
 .../internal/table/MutableRowTupleAdapterTest.java |  29 +++--
 .../table/type/NumericTypesSerializerTest.java     |  14 +--
 11 files changed, 229 insertions(+), 179 deletions(-)

diff --git 
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java
 
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java
index a3c0893..b9b4d59 100644
--- 
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java
+++ 
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java
@@ -36,8 +36,9 @@ public final class MarshallerUtil {
      * @param val Field value.
      * @param type Mapped type.
      * @return Serialized value size.
+     * @throws InvalidTypeException If type is unsupported.
      */
-    public static int getValueSize(Object val, NativeType type) {
+    public static int getValueSize(Object val, NativeType type) throws 
InvalidTypeException {
         switch (type.spec()) {
             case BYTES:
                 return ((byte[])val).length;
diff --git 
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/RowAssembler.java
 
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/RowAssembler.java
index e4f7032..154862f 100644
--- 
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/RowAssembler.java
+++ 
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/RowAssembler.java
@@ -38,11 +38,13 @@ import org.apache.ignite.internal.schema.ByteBufferRow;
 import org.apache.ignite.internal.schema.Column;
 import org.apache.ignite.internal.schema.Columns;
 import org.apache.ignite.internal.schema.DecimalNativeType;
+import org.apache.ignite.internal.schema.InvalidTypeException;
 import org.apache.ignite.internal.schema.NativeType;
 import org.apache.ignite.internal.schema.NativeTypeSpec;
 import org.apache.ignite.internal.schema.NativeTypes;
 import org.apache.ignite.internal.schema.NumberNativeType;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.schema.SchemaMismatchException;
 import org.apache.ignite.internal.schema.TemporalNativeType;
 
 import static 
org.apache.ignite.internal.schema.BinaryRow.RowFlags.KEY_FLAGS_OFFSET;
@@ -145,8 +147,9 @@ public class RowAssembler {
      * @param rowAsm Writes column value to assembler.
      * @param col Column.
      * @param val Value.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public static void writeValue(RowAssembler rowAsm, Column col, Object val) 
{
+    public static void writeValue(RowAssembler rowAsm, Column col, Object val) 
throws SchemaMismatchException {
         if (val == null) {
             rowAsm.appendNull();
 
@@ -235,7 +238,7 @@ public class RowAssembler {
                 break;
             }
             default:
-                throw new IllegalStateException("Unexpected value: " + 
col.type());
+                throw new InvalidTypeException("Unexpected value: " + 
col.type());
         }
     }
 
@@ -320,10 +323,11 @@ public class RowAssembler {
      * Appends {@code null} value for the current column to the chunk.
      *
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If the current column is not nullable.
      */
-    public RowAssembler appendNull() {
+    public RowAssembler appendNull() throws SchemaMismatchException {
         if (!curCols.column(curCol).nullable())
-            throw new IllegalArgumentException("Failed to set column (null was 
passed, but column is not nullable): " + curCols.column(curCol));
+            throw new SchemaMismatchException("Failed to set column (null was 
passed, but column is not nullable): " + curCols.column(curCol));
 
         setNull(curCol);
 
@@ -340,8 +344,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendByte(byte val) {
+    public RowAssembler appendByte(byte val) throws SchemaMismatchException {
         checkType(NativeTypes.INT8);
 
         buf.put(curOff, val);
@@ -359,8 +364,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendShort(short val) {
+    public RowAssembler appendShort(short val) throws SchemaMismatchException {
         checkType(NativeTypes.INT16);
 
         buf.putShort(curOff, val);
@@ -378,8 +384,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendInt(int val) {
+    public RowAssembler appendInt(int val) throws SchemaMismatchException {
         checkType(NativeTypes.INT32);
 
         buf.putInt(curOff, val);
@@ -397,8 +404,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendLong(long val) {
+    public RowAssembler appendLong(long val) throws SchemaMismatchException {
         checkType(NativeTypes.INT64);
 
         buf.putLong(curOff, val);
@@ -416,8 +424,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendFloat(float val) {
+    public RowAssembler appendFloat(float val) throws SchemaMismatchException {
         checkType(NativeTypes.FLOAT);
 
         buf.putFloat(curOff, val);
@@ -435,8 +444,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendDouble(double val) {
+    public RowAssembler appendDouble(double val) throws 
SchemaMismatchException {
         checkType(NativeTypes.DOUBLE);
 
         buf.putDouble(curOff, val);
@@ -454,8 +464,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendNumber(BigInteger val) {
+    public RowAssembler appendNumber(BigInteger val) throws 
SchemaMismatchException {
         checkType(NativeTypeSpec.NUMBER);
 
         Column col = curCols.column(curCol);
@@ -464,7 +475,7 @@ public class RowAssembler {
 
         //0 is a magic number for "unlimited precision"
         if (type.precision() > 0 && new BigDecimal(val).precision() > 
type.precision())
-            throw new IllegalArgumentException("Failed to set number value for 
column '" + col.name() + "' " +
+            throw new SchemaMismatchException("Failed to set number value for 
column '" + col.name() + "' " +
                 "(max precision exceeds allocated precision) " +
                 "[number=" + val + ", max precision=" + type.precision() + 
"]");
 
@@ -489,8 +500,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendDecimal(BigDecimal val) {
+    public RowAssembler appendDecimal(BigDecimal val) throws 
SchemaMismatchException {
         checkType(NativeTypeSpec.DECIMAL);
 
         Column col = curCols.column(curCol);
@@ -500,7 +512,7 @@ public class RowAssembler {
         val = val.setScale(type.scale(), RoundingMode.HALF_UP);
 
         if (val.precision() > type.precision())
-            throw new IllegalArgumentException("Failed to set decimal value 
for column '" + col.name() + "' " +
+            throw new SchemaMismatchException("Failed to set decimal value for 
column '" + col.name() + "' " +
                 "(max precision exceeds allocated precision)" +
                 " [decimal=" + val + ", max precision=" + type.precision() + 
"]");
 
@@ -525,8 +537,9 @@ public class RowAssembler {
      *
      * @param uuid Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendUuid(UUID uuid) {
+    public RowAssembler appendUuid(UUID uuid) throws SchemaMismatchException {
         checkType(NativeTypes.UUID);
 
         buf.putLong(curOff, uuid.getLeastSignificantBits());
@@ -545,8 +558,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendString(String val) {
+    public RowAssembler appendString(String val) throws 
SchemaMismatchException {
         checkType(NativeTypes.STRING);
 
         try {
@@ -573,8 +587,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendBytes(byte[] val) {
+    public RowAssembler appendBytes(byte[] val) throws SchemaMismatchException 
{
         checkType(NativeTypes.BYTES);
 
         buf.putBytes(curOff, val);
@@ -596,8 +611,9 @@ public class RowAssembler {
      *
      * @param bitSet Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendBitmask(BitSet bitSet) {
+    public RowAssembler appendBitmask(BitSet bitSet) throws 
SchemaMismatchException {
         Column col = curCols.column(curCol);
 
         checkType(NativeTypeSpec.BITMASK);
@@ -628,8 +644,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendDate(LocalDate val) {
+    public RowAssembler appendDate(LocalDate val) throws 
SchemaMismatchException {
         checkType(NativeTypes.DATE);
 
         int date = TemporalTypesHelper.encodeDate(val);
@@ -649,8 +666,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendTime(LocalTime val) {
+    public RowAssembler appendTime(LocalTime val) throws 
SchemaMismatchException {
         checkType(NativeTypeSpec.TIME);
 
         TemporalNativeType type = 
(TemporalNativeType)curCols.column(curCol).type();
@@ -670,8 +688,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendDateTime(LocalDateTime val) {
+    public RowAssembler appendDateTime(LocalDateTime val) throws 
SchemaMismatchException {
         checkType(NativeTypeSpec.DATETIME);
 
         TemporalNativeType type = 
(TemporalNativeType)curCols.column(curCol).type();
@@ -694,8 +713,9 @@ public class RowAssembler {
      *
      * @param val Column value.
      * @return {@code this} for chaining.
+     * @throws SchemaMismatchException If a value doesn't match the current 
column type.
      */
-    public RowAssembler appendTimestamp(Instant val) {
+    public RowAssembler appendTimestamp(Instant val) throws 
SchemaMismatchException {
         checkType(NativeTypeSpec.TIMESTAMP);
 
         TemporalNativeType type = 
(TemporalNativeType)curCols.column(curCol).type();
@@ -817,12 +837,13 @@ public class RowAssembler {
      * Checks that the type being appended matches the column type.
      *
      * @param type Type spec that is attempted to be appended.
+     * @throws SchemaMismatchException If given type doesn't match the current 
column type.
      */
     private void checkType(NativeTypeSpec type) {
         Column col = curCols.column(curCol);
 
         if (col.type().spec() != type)
-            throw new IllegalArgumentException("Failed to set column (int was 
passed, but column is of different " +
+            throw new SchemaMismatchException("Failed to set column (int was 
passed, but column is of different " +
                 "type): " + col);
     }
 
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
index 2bc1b70..3760fda 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.schema.marshaller;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.table.Tuple;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Tuple marshaller interface.
@@ -30,16 +31,18 @@ public interface TupleMarshaller {
      *
      * @param tuple Record tuple.
      * @return Table row with columns set from given tuples.
+     * @throws TupleMarshallerException If failed to marshal tuple.
      */
-    Row marshal(@NotNull Tuple tuple);
+    Row marshal(@NotNull Tuple tuple) throws TupleMarshallerException;
 
     /**
      * Marshal tuple key part only.
      *
      * @param tuple Record tuple with key columns only.
      * @return Table row with columns set from given tuples.
+     * @throws TupleMarshallerException If failed to marshal tuple.
      */
-    Row marshalKey(@NotNull Tuple tuple);
+    Row marshalKey(@NotNull Tuple tuple) throws TupleMarshallerException;
 
     /**
      * Marshals KV pair.
@@ -47,6 +50,7 @@ public interface TupleMarshaller {
      * @param keyTuple Key tuple.
      * @param valTuple Value tuple.
      * @return Table row with columns set from given tuples.
+     * @throws TupleMarshallerException If failed to marshal tuple.
      */
-    Row marshal(@NotNull Tuple keyTuple, Tuple valTuple);
+    Row marshal(@NotNull Tuple keyTuple, @Nullable Tuple valTuple) throws 
TupleMarshallerException;
 }
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java
similarity index 52%
copy from 
modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
copy to 
modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java
index 2bc1b70..18e4631 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java
@@ -17,36 +17,20 @@
 
 package org.apache.ignite.internal.schema.marshaller;
 
-import org.apache.ignite.internal.schema.row.Row;
-import org.apache.ignite.table.Tuple;
-import org.jetbrains.annotations.NotNull;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
 
 /**
- * Tuple marshaller interface.
+ * Throws when failed to marshal a tuple.
  */
-public interface TupleMarshaller {
+public class TupleMarshallerException extends IgniteInternalCheckedException {
     /**
-     * Marshals tuple.
+     * Creates a new grid exception with the given throwable as a cause and
+     * source of error message.
      *
-     * @param tuple Record tuple.
-     * @return Table row with columns set from given tuples.
+     * @param s
+     * @param cause Non-null throwable cause.
      */
-    Row marshal(@NotNull Tuple tuple);
-
-    /**
-     * Marshal tuple key part only.
-     *
-     * @param tuple Record tuple with key columns only.
-     * @return Table row with columns set from given tuples.
-     */
-    Row marshalKey(@NotNull Tuple tuple);
-
-    /**
-     * Marshals KV pair.
-     *
-     * @param keyTuple Key tuple.
-     * @param valTuple Value tuple.
-     * @return Table row with columns set from given tuples.
-     */
-    Row marshal(@NotNull Tuple keyTuple, Tuple valTuple);
+    public TupleMarshallerException(String s, Throwable cause) {
+        super(cause);
+    }
 }
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/TupleMarshallerImpl.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java
similarity index 74%
rename from 
modules/table/src/main/java/org/apache/ignite/internal/table/TupleMarshallerImpl.java
rename to 
modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java
index 336768c..a1077d4 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/table/TupleMarshallerImpl.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.table;
+package org.apache.ignite.internal.schema.marshaller;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -30,9 +30,9 @@ import org.apache.ignite.internal.schema.SchemaDescriptor;
 import org.apache.ignite.internal.schema.SchemaMismatchException;
 import org.apache.ignite.internal.schema.SchemaRegistry;
 import 
org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter;
-import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.internal.schema.row.RowAssembler;
+import org.apache.ignite.internal.table.InternalTable;
 import org.apache.ignite.internal.table.distributed.TableManager;
 import org.apache.ignite.schema.SchemaBuilders;
 import org.apache.ignite.schema.definition.ColumnDefinition;
@@ -40,6 +40,7 @@ import org.apache.ignite.schema.definition.ColumnType;
 import org.apache.ignite.schema.definition.SchemaManagementMode;
 import org.apache.ignite.table.Tuple;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import static 
org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
 import static 
org.apache.ignite.internal.schema.marshaller.MarshallerUtil.getValueSize;
@@ -74,57 +75,65 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
     }
 
     /** {@inheritDoc} */
-    @Override public Row marshal(@NotNull Tuple tuple) {
-        SchemaDescriptor schema = schemaReg.schema();
+    @Override public Row marshal(@NotNull Tuple tuple) throws 
TupleMarshallerException {
+        try {
+            SchemaDescriptor schema = schemaReg.schema();
 
-        InternalTuple keyTuple0 = toInternalTuple(schema, tuple, true);
-        InternalTuple valTuple0 = toInternalTuple(schema, tuple, false);
+            InternalTuple keyTuple0 = toInternalTuple(schema, tuple, true);
+            InternalTuple valTuple0 = toInternalTuple(schema, tuple, false);
 
-        while (valTuple0.knownColumns() + keyTuple0.knownColumns() != 
tuple.columnCount()) {
-            if (tbl.schemaMode() == SchemaManagementMode.STRICT)
-                throw new SchemaMismatchException("Value doesn't match 
schema.");
+            while (valTuple0.knownColumns() + keyTuple0.knownColumns() != 
tuple.columnCount()) {
+                if (tbl.schemaMode() == SchemaManagementMode.STRICT)
+                    throw new SchemaMismatchException("Value doesn't match 
schema.");
 
-            createColumns(extractColumnsType(tuple, extraColumnNames(tuple, 
schema)));
+                createColumns(extractColumnsType(tuple, 
extraColumnNames(tuple, schema)));
 
-            assert schemaReg.lastSchemaVersion() > schema.version();
+                assert schemaReg.lastSchemaVersion() > schema.version();
 
-            schema = schemaReg.schema();
+                schema = schemaReg.schema();
 
-            keyTuple0 = toInternalTuple(schema, tuple, true);
-            valTuple0 = toInternalTuple(schema, tuple, false);
-        }
+                keyTuple0 = toInternalTuple(schema, tuple, true);
+                valTuple0 = toInternalTuple(schema, tuple, false);
+            }
 
-        return buildRow(schema, keyTuple0, valTuple0);
+            return buildRow(schema, keyTuple0, valTuple0);
+        } catch (Exception ex) {
+            throw new TupleMarshallerException("Failed to marshal tuple.", ex);
+        }
     }
 
     /** {@inheritDoc} */
-    @Override public Row marshal(@NotNull Tuple keyTuple, Tuple valTuple) {
-        SchemaDescriptor schema = schemaReg.schema();
+    @Override public Row marshal(@NotNull Tuple keyTuple, @Nullable Tuple 
valTuple) throws TupleMarshallerException {
+        try {
+            SchemaDescriptor schema = schemaReg.schema();
 
-        InternalTuple keyTuple0 = toInternalTuple(schema, keyTuple, true);
-        InternalTuple valTuple0 = toInternalTuple(schema, valTuple, false);
+            InternalTuple keyTuple0 = toInternalTuple(schema, keyTuple, true);
+            InternalTuple valTuple0 = toInternalTuple(schema, valTuple, false);
 
-        while (true) {
-            if (keyTuple0.knownColumns() < keyTuple.columnCount())
-                throw new SchemaMismatchException("Key tuple contains extra 
columns: " + extraColumnNames(keyTuple, true, schema));
+            while (true) {
+                if (keyTuple0.knownColumns() < keyTuple.columnCount())
+                    throw new SchemaMismatchException("Key tuple contains 
extra columns: " + extraColumnNames(keyTuple, true, schema));
 
-            if (valTuple == null || valTuple0.knownColumns() == 
valTuple.columnCount())
-                break; // Nothing to do.
+                if (valTuple == null || valTuple0.knownColumns() == 
valTuple.columnCount())
+                    break; // Nothing to do.
 
-            if (tbl.schemaMode() == SchemaManagementMode.STRICT)
-                throw new SchemaMismatchException("Value doesn't match 
schema.");
+                if (tbl.schemaMode() == SchemaManagementMode.STRICT)
+                    throw new SchemaMismatchException("Value doesn't match 
schema.");
 
-            createColumns(extractColumnsType(valTuple, 
extraColumnNames(valTuple, false, schema)));
+                createColumns(extractColumnsType(valTuple, 
extraColumnNames(valTuple, false, schema)));
 
-            assert schemaReg.lastSchemaVersion() > schema.version();
+                assert schemaReg.lastSchemaVersion() > schema.version();
 
-            schema = schemaReg.schema();
+                schema = schemaReg.schema();
 
-            keyTuple0 = toInternalTuple(schema, keyTuple, true);
-            valTuple0 = toInternalTuple(schema, valTuple, false);
-        }
+                keyTuple0 = toInternalTuple(schema, keyTuple, true);
+                valTuple0 = toInternalTuple(schema, valTuple, false);
+            }
 
-        return buildRow(schema, keyTuple0, valTuple0);
+            return buildRow(schema, keyTuple0, valTuple0);
+        } catch (Exception ex) {
+            throw new TupleMarshallerException("Failed to marshal tuple.", ex);
+        }
     }
 
     /**
@@ -134,8 +143,9 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
      * @param keyTuple0 Internal key tuple.
      * @param valTuple0 Internal value tuple.
      * @return Row.
+     * @throws SchemaMismatchException If failed to write tuple column.
      */
-    @NotNull private Row buildRow(SchemaDescriptor schema, InternalTuple 
keyTuple0, InternalTuple valTuple0) {
+    @NotNull private Row buildRow(SchemaDescriptor schema, InternalTuple 
keyTuple0, InternalTuple valTuple0) throws SchemaMismatchException {
         RowAssembler rowBuilder = createAssembler(schema, keyTuple0, 
valTuple0);
 
         Columns columns = schema.keyColumns();
@@ -160,25 +170,29 @@ public class TupleMarshallerImpl implements 
TupleMarshaller {
     }
 
     /** {@inheritDoc} */
-    @Override public Row marshalKey(@NotNull Tuple keyTuple) {
-        final SchemaDescriptor schema = schemaReg.schema();
+    @Override public Row marshalKey(@NotNull Tuple keyTuple) throws 
TupleMarshallerException {
+        try {
+            final SchemaDescriptor schema = schemaReg.schema();
 
-        InternalTuple keyTuple0 = toInternalTuple(schema, keyTuple, true);
+            InternalTuple keyTuple0 = toInternalTuple(schema, keyTuple, true);
 
-        if (keyTuple0.knownColumns() < keyTuple.columnCount())
-            throw new SchemaMismatchException("Key tuple contains extra 
columns: " + extraColumnNames(keyTuple, true, schema));
+            if (keyTuple0.knownColumns() < keyTuple.columnCount())
+                throw new SchemaMismatchException("Key tuple contains extra 
columns: " + extraColumnNames(keyTuple, true, schema));
 
-        final RowAssembler rowBuilder = createAssembler(schema, keyTuple0, 
InternalTuple.NO_VALUE);
+            final RowAssembler rowBuilder = createAssembler(schema, keyTuple0, 
InternalTuple.NO_VALUE);
 
-        Columns cols = schema.keyColumns();
+            Columns cols = schema.keyColumns();
 
-        for (int i = 0, len = cols.length(); i < len; i++) {
-            final Column col = cols.column(i);
+            for (int i = 0, len = cols.length(); i < len; i++) {
+                final Column col = cols.column(i);
 
-            writeColumn(rowBuilder, col, keyTuple0);
-        }
+                writeColumn(rowBuilder, col, keyTuple0);
+            }
 
-        return new Row(schema, rowBuilder.build());
+            return new Row(schema, rowBuilder.build());
+        } catch (Exception ex) {
+            throw new TupleMarshallerException("Failed to marshal tuple.", ex);
+        }
     }
 
     /**
@@ -187,9 +201,10 @@ public class TupleMarshallerImpl implements 
TupleMarshaller {
      * @param schema Schema.
      * @param tuple Key or value tuple.
      * @param keyFlag If {@code true} marshal key columns, otherwise marshall 
value columns.
-     * @return Internal tuple
+     * @return Internal tuple.
+     * @throws SchemaMismatchException If tuple doesn't match the schema.
      */
-    private @NotNull InternalTuple toInternalTuple(SchemaDescriptor schema, 
Tuple tuple, boolean keyFlag) {
+    private @NotNull InternalTuple toInternalTuple(SchemaDescriptor schema, 
Tuple tuple, boolean keyFlag) throws SchemaMismatchException {
         if (tuple == null)
             return InternalTuple.NO_VALUE;
 
@@ -214,8 +229,7 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
                 nonNullVarlenSize += getValueSize(val, col.type());
                 nonNullVarlen++;
             }
-        }
-        else {
+        } else {
             for (int i = 0, len = columns.length(); i < len; i++) {
                 final Column col = columns.column(i);
 
@@ -228,8 +242,7 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
                     val = col.defaultValue();
 
                     defaults.put(col.name(), val);
-                }
-                else
+                } else
                     knownColumns++;
 
                 col.validate(val);
@@ -292,8 +305,9 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
      * @param tuple Tuple with column values.
      * @param colNames Column names that type info to be extracted.
      * @return Column types.
+     * @throws InvalidTypeException If failed to extract a type for tuple 
column value.
      */
-    private Set<ColumnDefinition> extractColumnsType(Tuple tuple, Set<String> 
colNames) {
+    private Set<ColumnDefinition> extractColumnsType(Tuple tuple, Set<String> 
colNames) throws InvalidTypeException {
         Set<ColumnDefinition> extraColumns = new HashSet<>();
 
         for (String colName : colNames) {
@@ -334,8 +348,9 @@ public class TupleMarshallerImpl implements TupleMarshaller 
{
      * @param rowAsm Row assembler.
      * @param col Column.
      * @param tup Internal tuple.
+     * @throws SchemaMismatchException If a tuple column value doesn't match 
the current column type.
      */
-    private void writeColumn(RowAssembler rowAsm, Column col, InternalTuple 
tup) {
+    private void writeColumn(RowAssembler rowAsm, Column col, InternalTuple 
tup) throws SchemaMismatchException {
         RowAssembler.writeValue(rowAsm, col, tup.value(col.name()));
     }
 
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
index 31ea280..b1bae5c 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
@@ -25,14 +25,17 @@ import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 import org.apache.ignite.internal.schema.BinaryRow;
 import org.apache.ignite.internal.schema.SchemaRegistry;
-import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.lang.IgniteException;
 import org.apache.ignite.table.InvokeProcessor;
 import org.apache.ignite.table.KeyValueView;
 import org.apache.ignite.table.Tuple;
 import org.apache.ignite.tx.Transaction;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Key-value view implementation for binary user-object representation.
@@ -67,7 +70,7 @@ public class KeyValueBinaryViewImpl extends AbstractTableView 
implements KeyValu
     @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple 
key) {
         Objects.requireNonNull(key);
 
-        Row kRow = marshaller().marshal(key, null); // Convert to portable 
format to pass TX/storage layer.
+        Row kRow = marshal(key, null); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.get(kRow, tx)  // Load async.
                 .thenApply(this::wrap) // Binary -> schema-aware row
@@ -83,7 +86,7 @@ public class KeyValueBinaryViewImpl extends AbstractTableView 
implements KeyValu
     @Override public @NotNull CompletableFuture<Map<Tuple, Tuple>> 
getAllAsync(@NotNull Collection<Tuple> keys) {
         Objects.requireNonNull(keys);
 
-        return tbl.getAll(keys.stream().map(k -> marsh.marshal(k, 
null)).collect(Collectors.toList()), tx)
+        return tbl.getAll(keys.stream().map(k -> marshal(k, 
null)).collect(Collectors.toList()), tx)
             .thenApply(ts -> 
ts.stream().filter(Objects::nonNull).map(this::wrap).collect(Collectors.toMap(TableRow::keyTuple,
 TableRow::valueTuple)));
     }
 
@@ -106,7 +109,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Void> putAsync(@NotNull Tuple 
key, Tuple val) {
         Objects.requireNonNull(key);
 
-        Row row = marshaller().marshal(key, val); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, val); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.upsert(row, tx);
     }
@@ -122,7 +125,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
 
         return tbl.upsertAll(pairs.entrySet()
             .stream()
-            .map(this::marshalPair)
+            .map(p -> marshal(p.getKey(), p.getValue()))
             .collect(Collectors.toList()), tx);
     }
 
@@ -135,7 +138,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Tuple> getAndPutAsync(@NotNull 
Tuple key, Tuple val) {
         Objects.requireNonNull(key);
 
-        Row row = marshaller().marshal(key, val); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, val); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.getAndUpsert(row, tx)
             .thenApply(this::wrap) // Binary -> schema-aware row
@@ -151,7 +154,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Boolean> 
putIfAbsentAsync(@NotNull Tuple key, Tuple val) {
         Objects.requireNonNull(key);
 
-        Row row = marshaller().marshal(key, val); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, val); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.insert(row, tx);
     }
@@ -165,7 +168,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Boolean> removeAsync(@NotNull 
Tuple key) {
         Objects.requireNonNull(key);
 
-        Row row = marshaller().marshal(key, null); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, null); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.delete(row, tx);
     }
@@ -180,7 +183,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
         Objects.requireNonNull(key);
         Objects.requireNonNull(val);
 
-        Row row = marshaller().marshal(key, val); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, val); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.deleteExact(row, tx);
     }
@@ -196,7 +199,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Collection<Tuple>> 
removeAllAsync(@NotNull Collection<Tuple> keys) {
         Objects.requireNonNull(keys);
 
-        return tbl.deleteAll(keys.stream().map(k -> marsh.marshal(k, 
null)).collect(Collectors.toList()), tx)
+        return tbl.deleteAll(keys.stream().map(k -> marshal(k, 
null)).collect(Collectors.toList()), tx)
                 .thenApply(t -> 
t.stream().filter(Objects::nonNull).map(this::wrap).map(TableRow::valueTuple).collect(Collectors.toList()));
     }
 
@@ -211,7 +214,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Tuple> 
getAndRemoveAsync(@NotNull Tuple key) {
         Objects.requireNonNull(key);
 
-        return tbl.getAndDelete(marsh.marshal(key, null), tx)
+        return tbl.getAndDelete(marshal(key, null), tx)
                 .thenApply(this::wrap)
                 .thenApply(TableRow::valueTuple);
     }
@@ -225,7 +228,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull 
Tuple key, Tuple val) {
         Objects.requireNonNull(key);
 
-        Row row = marshaller().marshal(key, val); // Convert to portable 
format to pass TX/storage layer.
+        Row row = marshal(key, val); // Convert to portable format to pass 
TX/storage layer.
 
         return tbl.replace(row, tx);
     }
@@ -239,8 +242,8 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull 
Tuple key, Tuple oldVal, Tuple newVal) {
         Objects.requireNonNull(key);
 
-        Row oldRow = marshaller().marshal(key, oldVal); // Convert to portable 
format to pass TX/storage layer.
-        Row newRow = marshaller().marshal(key, newVal); // Convert to portable 
format to pass TX/storage layer.
+        Row oldRow = marshal(key, oldVal); // Convert to portable format to 
pass TX/storage layer.
+        Row newRow = marshal(key, newVal); // Convert to portable format to 
pass TX/storage layer.
 
         return tbl.replace(oldRow, newRow, tx);
     }
@@ -254,7 +257,7 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     @Override public @NotNull CompletableFuture<Tuple> 
getAndReplaceAsync(@NotNull Tuple key, Tuple val) {
         Objects.requireNonNull(key);
 
-        return tbl.getAndReplace(marsh.marshal(key, val), tx)
+        return tbl.getAndReplace(marshal(key, val), tx)
             .thenApply(this::wrap)
             .thenApply(TableRow::valueTuple);
     }
@@ -301,10 +304,20 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
     }
 
     /**
-     * @return Marshaller.
+     * Marshal key-value pair to a row.
+     *
+     * @param key Key.
+     * @param val Value.
+     * @return Row.
+     * @throws IgniteException If failed to marshal key and/or value.
      */
-    private TupleMarshaller marshaller() {
-        return marsh;
+    private Row marshal(@NotNull Tuple key, @Nullable Tuple val) throws 
IgniteException {
+        try {
+            return marsh.marshal(key, val);
+        }
+        catch (TupleMarshallerException ex) {
+            throw new IgniteException(ex);
+        }
     }
 
     /**
@@ -317,14 +330,4 @@ public class KeyValueBinaryViewImpl extends 
AbstractTableView implements KeyValu
 
         return schemaReg.resolve(row);
     }
-
-    /**
-     * Marshals a key-value pair into the table row.
-     *
-     * @param pair A map entry represents the key-value pair.
-     * @return Row.
-     */
-    private Row marshalPair(Map.Entry<Tuple, Tuple> pair) {
-        return marshaller().marshal(pair.getKey(), pair.getValue());
-    }
 }
diff --git 
a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
 
b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
index b5843fe..89754a3 100644
--- 
a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
+++ 
b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
@@ -26,9 +26,11 @@ import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 import org.apache.ignite.internal.schema.BinaryRow;
 import org.apache.ignite.internal.schema.SchemaRegistry;
-import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.lang.IgniteException;
 import org.apache.ignite.table.InvokeProcessor;
 import org.apache.ignite.table.RecordView;
 import org.apache.ignite.table.Tuple;
@@ -62,7 +64,6 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         this.tblMgr = tblMgr;
     }
 
-
     /** {@inheritDoc} */
     @Override public RecordBinaryViewImpl withTransaction(Transaction tx) {
         return new RecordBinaryViewImpl(tbl, schemaReg, tblMgr, tx);
@@ -77,7 +78,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Tuple> getAsync(@NotNull Tuple 
keyRec) {
         Objects.requireNonNull(keyRec);
 
-        final Row keyRow = marshaller().marshalKey(keyRec); // Convert to 
portable format to pass TX/storage layer.
+        final Row keyRow = marshal(keyRec, true); // Convert to portable 
format to pass TX/storage layer.
 
         return tbl.get(keyRow, tx).thenApply(this::wrap);
     }
@@ -94,7 +95,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         HashSet<BinaryRow> keys = new HashSet<>(keyRecs.size());
 
         for (Tuple keyRec : keyRecs) {
-            final Row keyRow = marshaller().marshalKey(keyRec);
+            final Row keyRow = marshal(keyRec, true);
 
             keys.add(keyRow);
         }
@@ -111,7 +112,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Void> upsertAsync(@NotNull 
Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row keyRow = marshaller().marshal(rec);
+        final Row keyRow = marshal(rec, false);
 
         return tbl.upsert(keyRow, tx);
     }
@@ -128,7 +129,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         HashSet<BinaryRow> keys = new HashSet<>(recs.size());
 
         for (Tuple keyRec : recs) {
-            final Row keyRow = marshaller().marshal(keyRec);
+            final Row keyRow = marshal(keyRec, false);
 
             keys.add(keyRow);
         }
@@ -145,7 +146,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Tuple> 
getAndUpsertAsync(@NotNull Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row keyRow = marshaller().marshal(rec);
+        final Row keyRow = marshal(rec, false);
 
         return tbl.getAndUpsert(keyRow, tx).thenApply(this::wrap);
     }
@@ -159,7 +160,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Boolean> insertAsync(@NotNull 
Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row keyRow = marshaller().marshal(rec);
+        final Row keyRow = marshal(rec, false);
 
         return tbl.insert(keyRow, tx);
     }
@@ -176,7 +177,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         HashSet<BinaryRow> keys = new HashSet<>(recs.size());
 
         for (Tuple keyRec : recs) {
-            final Row keyRow = marshaller().marshal(keyRec);
+            final Row keyRow = marshal(keyRec, false);
 
             keys.add(keyRow);
         }
@@ -193,7 +194,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Boolean> replaceAsync(@NotNull 
Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row keyRow = marshaller().marshal(rec);
+        final Row keyRow = marshal(rec, false);
 
         return tbl.replace(keyRow, tx);
     }
@@ -208,8 +209,8 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         Objects.requireNonNull(oldRec);
         Objects.requireNonNull(newRec);
 
-        final Row oldRow = marshaller().marshal(oldRec);
-        final Row newRow = marshaller().marshal(newRec);
+        final Row oldRow = marshal(oldRec, false);
+        final Row newRow = marshal(newRec, false);
 
         return tbl.replace(oldRow, newRow, tx);
     }
@@ -223,7 +224,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Tuple> 
getAndReplaceAsync(@NotNull Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row keyRow = marshaller().marshal(rec);
+        final Row keyRow = marshal(rec, false);
 
         return tbl.getAndReplace(keyRow, tx).thenApply(this::wrap);
     }
@@ -237,7 +238,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Boolean> deleteAsync(@NotNull 
Tuple keyRec) {
         Objects.requireNonNull(keyRec);
 
-        final Row keyRow = marshaller().marshalKey(keyRec);
+        final Row keyRow = marshal(keyRec, true);
 
         return tbl.delete(keyRow, tx);
     }
@@ -251,7 +252,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Boolean> 
deleteExactAsync(@NotNull Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row row = marshaller().marshal(rec);
+        final Row row = marshal(rec, false);
 
         return tbl.deleteExact(row, tx);
     }
@@ -265,7 +266,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
     @Override public @NotNull CompletableFuture<Tuple> 
getAndDeleteAsync(@NotNull Tuple rec) {
         Objects.requireNonNull(rec);
 
-        final Row row = marshaller().marshalKey(rec);
+        final Row row = marshal(rec, true);
 
         return tbl.getAndDelete(row, tx).thenApply(this::wrap);
     }
@@ -282,7 +283,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         HashSet<BinaryRow> keys = new HashSet<>(recs.size());
 
         for (Tuple keyRec : recs) {
-            final Row keyRow = marshaller().marshalKey(keyRec);
+            final Row keyRow = marshal(keyRec, true);
 
             keys.add(keyRow);
         }
@@ -304,7 +305,7 @@ public class RecordBinaryViewImpl extends AbstractTableView 
implements RecordVie
         HashSet<BinaryRow> keys = new HashSet<>(recs.size());
 
         for (Tuple keyRec : recs) {
-            final Row keyRow = marshaller().marshal(keyRec);
+            final Row keyRow = marshal(keyRec, false);
 
             keys.add(keyRow);
         }
@@ -345,10 +346,22 @@ public class RecordBinaryViewImpl extends 
AbstractTableView implements RecordVie
     }
 
     /**
-     * @return Marshaller.
+     * Marshal a tuple to a row.
+     *
+     * @param tuple Tuple.
+     * @param keyOnly Marshal key part only if {@code true}, otherwise marshal 
both, key and value parts.
+     * @return Row.
+     * @throws IgniteException If failed to marshal tuple.
      */
-    private TupleMarshaller marshaller() {
-        return marsh;
+    private Row marshal(@NotNull Tuple tuple, boolean keyOnly) throws 
IgniteException {
+        try {
+            if (keyOnly)
+                return marsh.marshalKey(tuple);
+            else
+                return marsh.marshal(tuple);
+        } catch (TupleMarshallerException ex) {
+            throw new IgniteException(ex);
+        }
     }
 
     /**
diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java
index 7e236f5..6026ab8 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java
@@ -25,9 +25,10 @@ import org.apache.ignite.internal.schema.Columns;
 import org.apache.ignite.internal.schema.NativeTypes;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
 import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.registry.SchemaRegistryImpl;
 import org.apache.ignite.internal.schema.row.Row;
-import org.apache.ignite.internal.table.TupleMarshallerImpl;
 import org.apache.ignite.table.Tuple;
 import org.openjdk.jmh.annotations.Benchmark;
 import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -130,7 +131,7 @@ public class TupleMarshallerFixlenOnlyBenchmark {
      * @param bh Black hole.
      */
     @Benchmark
-    public void measureTupleBuildAndMarshallerCost(Blackhole bh) {
+    public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws 
TupleMarshallerException {
         final Columns cols = schema.valueColumns();
 
         final Tuple valBld = Tuple.create(cols.length());
diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java
index 766493f..5fa2486 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java
@@ -26,9 +26,10 @@ import org.apache.ignite.internal.schema.Column;
 import org.apache.ignite.internal.schema.Columns;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
 import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.registry.SchemaRegistryImpl;
 import org.apache.ignite.internal.schema.row.Row;
-import org.apache.ignite.internal.table.TupleMarshallerImpl;
 import org.apache.ignite.table.Tuple;
 import org.openjdk.jmh.annotations.Benchmark;
 import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -150,7 +151,7 @@ public class TupleMarshallerVarlenOnlyBenchmark {
      * @param bh Black hole.
      */
     @Benchmark
-    public void measureTupleBuildAndMarshallerCost(Blackhole bh) {
+    public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws 
TupleMarshallerException {
         final Columns cols = schema.valueColumns();
 
         final Tuple valBld = Tuple.create(cols.length());
diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
index 7f29074..54443a2 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
@@ -36,6 +36,8 @@ import org.apache.ignite.internal.schema.NativeTypes;
 import org.apache.ignite.internal.schema.SchemaAware;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
 import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
 import org.apache.ignite.internal.testframework.IgniteTestUtils;
@@ -62,6 +64,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Tests server tuple builder implementation.
@@ -198,7 +201,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testKeyValueChunks() {
+    public void testKeyValueChunks() throws TupleMarshallerException {
         SchemaDescriptor schema = new SchemaDescriptor(
             42,
             new Column[]{new Column("id", NativeTypes.INT64, false)},
@@ -238,7 +241,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testRowTupleMutability() {
+    public void testRowTupleMutability() throws TupleMarshallerException {
         TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(schema));
 
         Row row = new Row(schema, new 
ByteBufferRow(marshaller.marshal(Tuple.create().set("id", 1L).set("name", 
"Shirt")).bytes()));
@@ -265,7 +268,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testKeyValueTupleMutability() {
+    public void testKeyValueTupleMutability() throws TupleMarshallerException {
         TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(schema));
 
         Row row = new Row(schema, new 
ByteBufferRow(marshaller.marshal(Tuple.create().set("id", 1L).set("name", 
"Shirt")).bytes()));
@@ -294,7 +297,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testRowTupleSchemaAwareness() {
+    public void testRowTupleSchemaAwareness() throws TupleMarshallerException {
         TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(schema));
 
         Row row = new Row(schema, new 
ByteBufferRow(marshaller.marshal(Tuple.create().set("id", 1L).set("name", 
"Shirt")).bytes()));
@@ -317,7 +320,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testKeyValueTupleSchemaAwareness() {
+    public void testKeyValueTupleSchemaAwareness() throws 
TupleMarshallerException {
         TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(schema));
 
         Row row = new Row(schema, new 
ByteBufferRow(marshaller.marshal(Tuple.create().set("id", 1L).set("name", 
"Shirt")).bytes()));
@@ -342,7 +345,7 @@ public class MutableRowTupleAdapterTest {
     }
 
     @Test
-    public void testVariousColumnTypes() {
+    public void testVariousColumnTypes() throws TupleMarshallerException {
         Random rnd = new Random();
 
         TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(fullSchema));
@@ -557,13 +560,17 @@ public class MutableRowTupleAdapterTest {
     }
 
     private Tuple getTuple() {
-        Tuple original = Tuple.create()
-                             .set("id", 3L)
-                             .set("name", "Shirt");
+        try {
+            Tuple original = Tuple.create()
+                .set("id", 3L)
+                .set("name", "Shirt");
 
-        TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, new 
DummySchemaManagerImpl(schema));
+            TupleMarshaller marshaller = new TupleMarshallerImpl(null, tbl, 
new DummySchemaManagerImpl(schema));
 
-        return TableRow.tuple(new Row(schema, new 
ByteBufferRow(marshaller.marshal(original).bytes())));
+            return TableRow.tuple(new Row(schema, new 
ByteBufferRow(marshaller.marshal(original).bytes())));
+        } catch (TupleMarshallerException e) {
+            return fail();
+        }
     }
 
     /**
diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java
index 56346af..ebcdf87 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.table.type;
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.RoundingMode;
@@ -30,9 +29,10 @@ import 
org.apache.ignite.internal.schema.InvalidTypeException;
 import org.apache.ignite.internal.schema.NativeTypes;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
 import org.apache.ignite.internal.schema.marshaller.TupleMarshaller;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException;
+import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl;
 import org.apache.ignite.internal.schema.row.Row;
 import org.apache.ignite.internal.table.InternalTable;
-import org.apache.ignite.internal.table.TupleMarshallerImpl;
 import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
 import org.apache.ignite.internal.util.Pair;
 import org.apache.ignite.schema.definition.SchemaManagementMode;
@@ -115,7 +115,7 @@ public class NumericTypesSerializerTest {
      */
     @ParameterizedTest
     @MethodSource("numbers")
-    public void testNumber(Pair<BigInteger, BigInteger> pair) {
+    public void testNumber(Pair<BigInteger, BigInteger> pair) throws 
TupleMarshallerException {
         schema = new SchemaDescriptor(
             42,
             new Column[] {new Column("key", NativeTypes.INT64, false)},
@@ -194,7 +194,7 @@ public class NumericTypesSerializerTest {
      *
      */
     @Test
-    public void testStringDecimalSpecialCase() {
+    public void testStringDecimalSpecialCase() throws TupleMarshallerException 
{
         schema = new SchemaDescriptor(
             42,
             new Column[] {new Column("key", NativeTypes.INT64, false)},
@@ -218,7 +218,7 @@ public class NumericTypesSerializerTest {
      */
     @ParameterizedTest
     @MethodSource("stringDecimalRepresentation")
-    public void testUpscaleForDecimal(String decimalStr) {
+    public void testUpscaleForDecimal(String decimalStr) throws 
TupleMarshallerException {
         schema = new SchemaDescriptor(
             42,
             new Column[] {new Column("key", NativeTypes.INT64, false)},
@@ -242,7 +242,7 @@ public class NumericTypesSerializerTest {
      *
      */
     @Test
-    public void testDecimalMaxScale() {
+    public void testDecimalMaxScale() throws TupleMarshallerException {
         schema = new SchemaDescriptor(
             42,
             new Column[] {new Column("key", NativeTypes.INT64, false)},
@@ -267,7 +267,7 @@ public class NumericTypesSerializerTest {
      */
     @ParameterizedTest
     @MethodSource("sameDecimals")
-    public void testSameBinaryRepresentation(Pair<BigInteger, BigInteger> 
pair) throws IOException {
+    public void testSameBinaryRepresentation(Pair<BigInteger, BigInteger> 
pair) throws Exception {
         schema = new SchemaDescriptor(
             42,
             new Column[] {new Column("key", NativeTypes.INT64, false)},

Reply via email to