You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tl...@apache.org on 2021/12/09 18:51:38 UTC
[ignite] branch master updated: IGNITE-16043 added check for not null reader in BinaryObjectBuilderImpl (#9637)
This is an automated email from the ASF dual-hosted git repository.
tledkov 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 2968c09 IGNITE-16043 added check for not null reader in BinaryObjectBuilderImpl (#9637)
2968c09 is described below
commit 2968c0983960726e6247ba2f153ec52e368cc0bf
Author: Andrey Belyaev <48...@users.noreply.github.com>
AuthorDate: Thu Dec 9 21:51:01 2021 +0300
IGNITE-16043 added check for not null reader in BinaryObjectBuilderImpl (#9637)
---
.../binary/builder/BinaryObjectBuilderImpl.java | 4 ++-
.../BinaryObjectBuilderAdditionalSelfTest.java | 39 ++++++++++++++++++----
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index de4296b..c1f9e60 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -549,13 +549,15 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (val == REMOVED_FIELD_MARKER)
return null;
}
- else {
+ else if (reader != null) {
ensureReadCacheInit();
int fldId = ctx.fieldId(typeId, name);
val = readCache.get(fldId);
}
+ else
+ return null;
return (T)BinaryUtils.unwrapLazy(val);
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index ee0d851..1784813 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -1975,6 +1975,33 @@ public class BinaryObjectBuilderAdditionalSelfTest extends AbstractBinaryArraysT
}
/**
+ * @throws Exception If fails
+ */
+ @Test
+ public void testGetNotAssignedFieldInEmptyBuilder() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType")
+ .setField("w", "wewe");
+
+ assertNull(builder.getField("field"));
+ assertEquals("wewe", builder.getField("w"));
+ }
+
+ /**
+ * @throws Exception If fails
+ */
+ @Test
+ public void testGetNotAssignedFieldInBuilder() {
+ GridBinaryTestClasses.TestObjectContainer testObjectContainer = new GridBinaryTestClasses.TestObjectContainer();
+ testObjectContainer.foo = "binaryCachedValue";
+ BinaryObjectBuilderImpl builder = wrap(testObjectContainer);
+ builder.setField("w", "wewe");
+
+ assertNull(builder.getField("field"));
+ assertEquals("wewe", builder.getField("w"));
+ assertEquals("binaryCachedValue", builder.getField("foo"));
+ }
+
+ /**
*
*/
private void testCollectionHandlePossible(Collection<Object> src, Collection<Object> modified, Object obj) {
@@ -2014,11 +2041,11 @@ public class BinaryObjectBuilderAdditionalSelfTest extends AbstractBinaryArraysT
assertEquals(firstObj.get(), deserialized.obj);
assertSame(secondObj.get(), deserialized.obj);
-
+
BinaryObject anotherObject = wrap(listHolder).build();
-
+
BinaryObjectBuilder bob = anotherObject.toBuilder().build().toBuilder().build().toBuilder();
-
+
assertSame(bob.getField("firstCol"), bob.getField("firstCol"));
assertSame(bob.getField("firstCol"), bob.getField("secondCol"));
}
@@ -2055,11 +2082,11 @@ public class BinaryObjectBuilderAdditionalSelfTest extends AbstractBinaryArraysT
assertEquals(deserialized.firstMap.get(key), deserialized.valObj);
assertSame(deserialized.secondMap.get(key), deserialized.valObj);
-
+
BinaryObject anotherObject = wrap(mapsHolder).build();
-
+
BinaryObjectBuilder bob = anotherObject.toBuilder().build().toBuilder().build().toBuilder();
-
+
assertSame(bob.getField("firstMap"), bob.getField("firstMap"));
assertSame(bob.getField("firstMap"), bob.getField("secondMap"));
}