You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2019/06/24 10:13:48 UTC
[ignite] branch master updated: IGNITE-11919: Change message format
for incompatible fields' types changes. This closes #6618.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new a468662 IGNITE-11919: Change message format for incompatible fields' types changes. This closes #6618.
a468662 is described below
commit a4686625c91d464bb07a4314a6f167c85a439c6d
Author: palmuhal <pa...@gmail.ru>
AuthorDate: Mon Jun 24 13:13:29 2019 +0300
IGNITE-11919: Change message format for incompatible fields' types changes. This closes #6618.
---
.../apache/ignite/internal/binary/BinaryUtils.java | 9 ++---
...gnitePdsBinaryMetadataOnClusterRestartTest.java | 40 +++++++++++++---------
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 640cf1b..7139b8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -1041,10 +1041,11 @@ public class BinaryUtils {
if (!F.eq(oldFieldTypeName, newFieldTypeName)) {
throw new BinaryObjectException(
- "Binary type has different field types [" + "typeName=" + oldMeta.typeName() +
- ", fieldName=" + newField.getKey() +
- ", fieldTypeName1=" + oldFieldTypeName +
- ", fieldTypeName2=" + newFieldTypeName + ']'
+ "Type '" + oldMeta.typeName() + "' with typeId " + oldMeta.typeId()
+ + " has a different/incorrect type for field '" + newField.getKey()
+ + "'. Expected '" + oldFieldTypeName + "' but '" + newFieldTypeName
+ + "' was provided. Field type's modification is unsupported, clean {root_path}/marshaller " +
+ "and {root_path}/binary_meta directories if the type change is required."
);
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java
index 10cd553..c7c3942 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsBinaryMetadataOnClusterRestartTest.java
@@ -41,6 +41,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.WALMode;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -312,6 +313,8 @@ public class IgnitePdsBinaryMetadataOnClusterRestartTest extends GridCommonAbstr
cache.put(0, bObj);
+ int createdTypeId = igniteA.binary().type(DYNAMIC_TYPE_NAME).typeId();
+
stopAllGrids();
Ignite igniteC = startGridInASeparateWorkDir("C");
@@ -334,24 +337,27 @@ public class IgnitePdsBinaryMetadataOnClusterRestartTest extends GridCommonAbstr
startGridInASeparateWorkDir("A");
- boolean exceptedExceptionThrown = false;
- try {
- startGridInASeparateWorkDir("B");
- }
- catch (Exception e) {
- if (e.getCause() != null && e.getCause().getCause() != null) {
- if (e.getCause().getCause().getMessage().contains(
- String.format("[typeName=%s, fieldName=%s, fieldTypeName1=int, fieldTypeName2=long]",
- DYNAMIC_TYPE_NAME,
- decimalFieldName)
- ))
- exceptedExceptionThrown = true;
- }
- else
- throw e;
- }
+ String expectedMsg = String.format(
+ "Type '%s' with typeId %d has a different/incorrect type for field '%s'. Expected 'int' but 'long' was " +
+ "provided. Field type's modification is unsupported, clean {root_path}/marshaller and " +
+ "{root_path}/binary_meta directories if the type change is required.",
+ DYNAMIC_TYPE_NAME,
+ createdTypeId,
+ decimalFieldName);
+
+ Throwable thrown = GridTestUtils.assertThrows(
+ log,
+ () -> startGridInASeparateWorkDir("B"),
+ Exception.class,
+ null);
+
+ assertNotNull(thrown.getCause());
+ assertNotNull(thrown.getCause().getCause());
+
+ String actualMsg = thrown.getCause().getCause().getMessage();
- assertTrue(exceptedExceptionThrown);
+ assertTrue("Cause is not correct [expected='" + expectedMsg + "', actual='" + actualMsg + "'].",
+ actualMsg.contains(expectedMsg));
}
/** */