IGNITE-9794 Handle UnregisteredBinaryTypeException on metadata registration under topology lock. - Fixes #4916.
Signed-off-by: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
index 87c4f3e..7d138a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
@@ -26,6 +26,7 @@
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.UnregisteredBinaryTypeException;
import org.apache.ignite.internal.UnregisteredClassException;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
@@ -156,7 +157,7 @@
write0(obj, writer);
}
catch (Exception ex) {
- if (ex instanceof UnregisteredClassException)
+ if (ex instanceof UnregisteredClassException || ex instanceof UnregisteredBinaryTypeException)
throw ex;
if (S.INCLUDE_SENSITIVE && !F.isEmpty(name))
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java
index 73dae4b..c7c3757 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataRegistrationInsideEntryProcessorTest.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.cache;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.cache.processor.EntryProcessor;
@@ -40,7 +40,7 @@
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder()
- .setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
+ .setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
return new IgniteConfiguration()
.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder))
@@ -60,9 +60,9 @@
cache.invoke(i, new CustomProcessor());
}
catch (Exception e) {
- Map<Integer, CustomObj> value = cache.get(1);
+ Map<Integer, CustomObj> val = cache.get(1);
- if ((value != null) && (value.get(1) != null) && (value.get(1).getObj() == CustomEnum.ONE))
+ if ((val != null) && (val.get(1).anEnum == CustomEnum.ONE) && val.get(1).obj.data.equals("test"))
System.out.println("Data was saved.");
else
System.out.println("Data wasn't saved.");
@@ -82,7 +82,7 @@
Object... objects) throws EntryProcessorException {
Map<Integer, CustomObj> map = new HashMap<>();
- map.put(1, new CustomObj(CustomEnum.ONE));
+ map.put(1, new CustomObj(new CustomInnerObject("test"), CustomEnum.ONE));
entry.setValue(map);
@@ -95,27 +95,20 @@
*/
private static class CustomObj {
/** Object. */
- private final Object obj;
+ private final CustomInnerObject obj;
+
+ /** Enum. */
+ private final CustomEnum anEnum;
/**
* @param obj Object.
+ * @param anEnum Enum.
*/
- public CustomObj(Object obj) {
+ CustomObj(
+ CustomInnerObject obj,
+ CustomEnum anEnum) {
this.obj = obj;
- }
-
- /**
- * @param val Value.
- */
- public static CustomObj valueOf(int val) {
- return new CustomObj(val);
- }
-
- /**
- *
- */
- public Object getObj() {
- return obj;
+ this.anEnum = anEnum;
}
}
@@ -138,4 +131,18 @@
}
}
+ /**
+ *
+ */
+ private static class CustomInnerObject {
+ /** */
+ private final String data;
+
+ /**
+ * @param data Data.
+ */
+ CustomInnerObject(String data) {
+ this.data = data;
+ }
+ }
}
\ No newline at end of file