-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC4J-569 Correct EOS character handling #671
Conversation
@rpastrana please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpmcmu a couple of comments beyond our offline discussion...
@@ -475,10 +475,13 @@ else if (fd.getDataLen() == 8) | |||
case STRING: | |||
{ | |||
String value = fieldValue != null ? (String) fieldValue : ""; | |||
int eosIdx = value.indexOf('\0'); | |||
if (eosIdx > -1) | |||
if (fd.getFieldType() == FieldType.VAR_STRING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: why not introduce nullByte (from L:614) earlier or as static final and use that throughout instead of the literal '\0'
|| data[data.length - 1] != nullByte | ||
|| data[data.length - 2] != nullByte; | ||
if (needsNullAdded) { | ||
this.buffer.put(nullByte); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate lines
boolean needsNullAdded = data.length < 2 | ||
|| data[data.length - 1] != nullByte | ||
|| data[data.length - 2] != nullByte; | ||
if (needsNullAdded) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formating
@@ -88,6 +88,93 @@ public void readWithForcedTimeoutTest() throws Exception | |||
assertEquals("Not all records loaded",expectedCounts[0], records.size()); | |||
} | |||
|
|||
@Test | |||
public void allCharsNullTest() throws Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor but name implies this is testing a value w/ all nulls, I think nullCharTests might be a little more accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Modified BinaryRecordWriter to only truncate strings at EOS in var strings - Added unit test that verifies read / write all of Unicode chars and mid EOS Signed-off-by: James McMullan [email protected]
@rpastrana squashed, merging |
Signed-off-by: James McMullan [email protected]
Type of change:
Checklist:
Testing: