-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fix Corruption issue. #524
Conversation
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.
I am new to the project, but changes look good
formats/protobuf/src/main/java/io/cloudevents/protobuf/ProtoDataWrapper.java
Show resolved
Hide resolved
byte[] raw1 = format.serialize(event); | ||
io.cloudevents.CloudEvent act1 = format.deserialize(raw1); | ||
assertThat(event).withFailMessage("Mismatch on 1st round trip").isEqualTo(act1); | ||
|
||
// 2nd Round Trip | ||
byte[] raw2 = format.serialize(act1); | ||
io.cloudevents.CloudEvent act2 = format.deserialize(raw2); | ||
assertThat(event).withFailMessage("Mismatch on 2nd round trip").isEqualTo(act2); | ||
|
||
// 3rd Time's a charm | ||
byte[] raw3 = format.serialize(act2); | ||
io.cloudevents.CloudEvent act3 = format.deserialize(raw3); | ||
assertThat(event).withFailMessage("Mismatch on 3rd round trip").isEqualTo(act3); |
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.
I would compare the actual bytes with each other in addition to the event
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.
This test is more around asserting that the CloudEvent Object is consistent across the various serialize/deserialize operations than the wire-format.
If we wanted to add that level of check I'd suggest re-working the equals() implementation from your prior comment.
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.
What we make sure by comparing additionally raw bytes is that also the equals
method is correct
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.
Added new UnitTests to address byte[] equality.
Thanks @JemDay |
I think I'd like to roll-in a fix to address the inconsistencies raised by @mishap4 - that might simplify the implementation a bit more as well. |
formats/protobuf/src/test/java/io/cloudevents/protobuf/ProtobufFormatTest.java
Outdated
Show resolved
Hide resolved
byte[] raw1 = format.serialize(event); | ||
io.cloudevents.CloudEvent act1 = format.deserialize(raw1); | ||
assertThat(event).withFailMessage("Mismatch on 1st round trip").isEqualTo(act1); | ||
|
||
// 2nd Round Trip | ||
byte[] raw2 = format.serialize(act1); | ||
io.cloudevents.CloudEvent act2 = format.deserialize(raw2); | ||
assertThat(event).withFailMessage("Mismatch on 2nd round trip").isEqualTo(act2); | ||
|
||
// 3rd Time's a charm | ||
byte[] raw3 = format.serialize(act2); | ||
io.cloudevents.CloudEvent act3 = format.deserialize(raw3); | ||
assertThat(event).withFailMessage("Mismatch on 3rd round trip").isEqualTo(act3); |
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.
What we make sure by comparing additionally raw bytes is that also the equals
method is correct
formats/protobuf/src/main/java/io/cloudevents/protobuf/ProtoDataWrapper.java
Show resolved
Hide resolved
I will get some additional/refactored tests in tomorrow whilst retaining backward compatibility |
I think the various comments are addressed now .. There is more change than expected in the ProtobuffFormatTest file as I (foolishly) reformatted to address the review comment ... |
…ult in corrupted data if the data was a protobuf message object. Introduced equality checks for ProtoDataWrapper. Refactored and cleaned up data-wrappers. Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
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.
Thank you!
LGTM
… several times (cloudevents#524) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes cloudevents#523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
… several times (#524) (#525) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes #523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
… several times (cloudevents#524) Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object. - Introduced equality checks for ProtoDataWrapper. - Refactored and cleaned up data-wrappers. Fixes cloudevents#523 Signed-off-by: Jem Day <Jem.Day@cliffhanger.com> Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
Fixed issue where mutiple serialize/de-serialize operations would result in corrupted data if the data was a protobuf message object.
Introduced equality checks for ProtoDataWrapper.
Refactored and cleaned up data-wrappers.
Fixes #523