Skip to content

Commit

Permalink
chore: if the bool field is null set the inlined boolean as null (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoramirez authored Aug 6, 2024
1 parent 83646ce commit 51d3338
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ public void copy(GenericHollowObject rec, Object pojo) {
unsafe.putObject(pojo, fieldOffset, rec.getBytes(fieldName));
break;
case INLINED_BOOLEAN:
unsafe.putObject(pojo, fieldOffset, Boolean.valueOf(rec.getBoolean(fieldName)));
if (!rec.isNull(fieldName)) {
unsafe.putObject(pojo, fieldOffset, Boolean.valueOf(rec.getBoolean(fieldName)));
}
break;
case INLINED_INT:
int inlinedIntValue = rec.getInt(fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,20 @@ public void testNullablesSimpleTypes() {
TypeWithAllSimpleTypes result = mapper.readHollowRecord(obj);
Assert.assertEquals(Integer.valueOf(1), result.boxedIntegerField);
Assert.assertEquals(Character.valueOf('a'), result.boxedCharField);
Assert.assertNull(result.boxedFloatField);
Assert.assertNull(result.boxedBooleanField);
Assert.assertNull(result.boxedDoubleField);
Assert.assertNull(result.boxedFloatField);
Assert.assertNull(result.boxedLongField);
Assert.assertNull(result.boxedShortField);
Assert.assertNull(result.boxedByteField);
Assert.assertEquals(0, result.primitiveIntegerField);
Assert.assertFalse(result.primitiveBooleanField);
Assert.assertEquals(0.0, result.primitiveDoubleField, 0);
Assert.assertEquals(0.0f, result.primitiveFloatField, 0);
Assert.assertEquals(0L, result.primitiveLongField);
Assert.assertEquals(0, result.primitiveShortField);
Assert.assertEquals(0, result.primitiveByteField);
Assert.assertEquals(false, result.inlinedBooleanField);
Assert.assertNull(result.inlinedBooleanField);
Assert.assertEquals(Long.valueOf(4L), result.inlinedLongField);
Assert.assertNull(result.inlinedIntegerField);
Assert.assertNull(result.inlinedDoubleField);
Expand Down

0 comments on commit 51d3338

Please sign in to comment.