You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/12/09 15:19:26 UTC

[GitHub] [ignite] andreybell91 commented on a change in pull request #9637: IGNITE-16043 added check for not null reader in BinaryObjectBuilderImpl

andreybell91 commented on a change in pull request #9637:
URL: https://github.com/apache/ignite/pull/9637#discussion_r765889760



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
##########
@@ -549,12 +549,14 @@ private void ensureReadCacheInit() {
             if (val == REMOVED_FIELD_MARKER)
                 return null;
         }
-        else {
+        else if (reader != null) {
             ensureReadCacheInit();
 
             int fldId = ctx.fieldId(typeId, name);
 
             val = readCache.get(fldId);
+        } else {

Review comment:
       Fixed

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
##########
@@ -1974,6 +1974,40 @@ public void testBuilderReusage() throws Exception {
         assertEquals("val2", builder.build().field("f1"));
     }
 
+    /**
+     * @throws Exception If fails
+     */
+    @Test
+    public void testGetFieldForNotAssignedValInEmptyBuilder() {
+        BinaryObjectBuilder builder = binaries().builder("SomeType")
+                .setField("w", "wewe");
+
+        String fieldValue = builder.getField("field");
+        String wValue = builder.getField("w");
+
+        assertNull(fieldValue);
+        assertEquals("wewe", wValue);

Review comment:
       Fixed

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
##########
@@ -1974,6 +1974,40 @@ public void testBuilderReusage() throws Exception {
         assertEquals("val2", builder.build().field("f1"));
     }
 
+    /**
+     * @throws Exception If fails
+     */
+    @Test
+    public void testGetFieldForNotAssignedValInEmptyBuilder() {
+        BinaryObjectBuilder builder = binaries().builder("SomeType")
+                .setField("w", "wewe");
+
+        String fieldValue = builder.getField("field");
+        String wValue = builder.getField("w");
+
+        assertNull(fieldValue);
+        assertEquals("wewe", wValue);
+    }
+
+    /**
+     * @throws Exception If fails
+     */
+    @Test
+    public void testGetFieldForNotAssignedValInBuilder() {
+        GridBinaryTestClasses.TestObjectContainer testObjectContainer = new GridBinaryTestClasses.TestObjectContainer();
+        testObjectContainer.foo = "binaryCachedValue";
+        BinaryObjectBuilderImpl builder = wrap(testObjectContainer);
+        builder.setField("w", "wewe");
+
+        String fieldValue = builder.getField("field");
+        String wValue = builder.getField("w");
+        String fooValue = builder.getField("foo");
+
+        assertNull(fieldValue);
+        assertEquals("wewe", wValue);
+        assertEquals("binaryCachedValue", fooValue);

Review comment:
       Fixed

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
##########
@@ -1974,6 +1974,40 @@ public void testBuilderReusage() throws Exception {
         assertEquals("val2", builder.build().field("f1"));
     }
 
+    /**
+     * @throws Exception If fails
+     */
+    @Test
+    public void testGetFieldForNotAssignedValInEmptyBuilder() {

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org