Skip to content
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

provide more info when SBCF are different #771

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/emissary/core/IBaseDataObjectDiffHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.InputStream;
import java.nio.channels.Channels;
import java.nio.channels.SeekableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -157,8 +158,10 @@ public static void diff(final SeekableByteChannelFactory sbcf1, final SeekableBy
InputStream is1 = Channels.newInputStream(sbc1);
InputStream is2 = Channels.newInputStream(sbc2)) {
if (!IOUtils.contentEquals(is1, is2)) {
differences.add(String.format("%s not equal. 1.cs=%s 2.cs=%s",
identifier, sbc1.size(), sbc2.size()));
differences.add(String.format("%s not equal. 1.is=%s 2.is=%s",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't want to spit out a string representation of the entire payload; that could be well over a GB for each object being compared.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I hadn't considered that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have it display a string representation of the first x characters? Where x is set to 64 for ease of debugging

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider making that an option, but it would only be helpful if 1) the payload is text-like and decodes well using UTF_8 2) the difference occurs within the first few bytes.

identifier,
IOUtils.toString(Channels.newInputStream(sbcf1.create()), StandardCharsets.UTF_8),
IOUtils.toString(Channels.newInputStream(sbcf2.create()), StandardCharsets.UTF_8)));
}
} catch (IOException e) {
differences.add(String.format("Failed to compare %s: %s", identifier, e.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static void checkAnswers(final Document answers, final IBaseDataObject pa
final String differences = PlaceComparisonHelper.checkDifferences(expectedIbdo, payload, expectedAttachments,
attachments, placeName, DIFF_CHECK);

assertNull(differences, differences);
assertNull(differences);

final List<SimplifiedLogEvent> expectedSimplifiedLogEvents = getSimplifiedLogEvents(parent);

Expand Down