Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8253876: jdk/test/lib/hexdump/ASN1FormatterTest.java fails with "Asse…
…rtionError: Lines expected [126] but found [202]"

Reviewed-by: shade, lancea
  • Loading branch information
Roger Riggs committed Oct 7, 2020
1 parent db3053d commit 38159d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 0 additions & 3 deletions test/lib-test/ProblemList.txt
Expand Up @@ -37,6 +37,3 @@
# More than one label is allowed but must be on the same line.
#
#############################################################################


jdk/test/lib/hexdump/ASN1FormatterTest.java 8253876 generic-all
2 changes: 1 addition & 1 deletion test/lib-test/jdk/test/lib/hexdump/ASN1FormatterTest.java
Expand Up @@ -102,7 +102,7 @@ static void dumpPEM() throws IOException {
}

@Test
static void testIndefinate() {
static void testIndefinite() {
byte[] bytes = {0x24, (byte) 0x80, 4, 2, 'a', 'b', 4, 2, 'c', 'd', 0, 0};
HexPrinter p = HexPrinter.simple()
.formatter(ASN1Formatter.formatter(), "; ", 100);
Expand Down
17 changes: 11 additions & 6 deletions test/lib/jdk/test/lib/hexdump/ASN1Formatter.java
Expand Up @@ -165,8 +165,12 @@ private int annotate(DataInputStream in, Appendable out, int available, String p
// multi-byte encoded length
int nbytes = len & 0x7f;
if (nbytes > 4) {
out.append("***** Tag: " + tagName(tag) +
", Range of length error: " + len + " bytes" + System.lineSeparator());
out.append("***** Tag: ")
.append(tagName(tag))
.append(", Range of length error: ")
.append(Integer.toString(len))
.append(" bytes");
out.append(System.lineSeparator());
return available; // return the unread length
}
len = 0;
Expand All @@ -185,9 +189,10 @@ private int annotate(DataInputStream in, Appendable out, int available, String p
out.append(prefix); // start with indent
switch (tag) {
case TAG_EndOfContent: // End-of-contents octets; len == 0
out.append("END-OF-CONTENT " + System.lineSeparator());
// end of indefinite-length constructed, return any remaining
return 0; // unknown, but nothing left
out.append("END-OF-CONTENT");
out.append(System.lineSeparator());
// end of indefinite-length constructed, return zero remaining
return 0;
case TAG_Integer:
case TAG_Enumerated:
switch (len) {
Expand Down Expand Up @@ -319,7 +324,7 @@ private int annotate(DataInputStream in, Appendable out, int available, String p
}
}
}
out.append(System.lineSeparator()); // End with EOL
out.append(System.lineSeparator());
}
return available;
}
Expand Down
4 changes: 3 additions & 1 deletion test/lib/jdk/test/lib/hexdump/HexPrinter.java
Expand Up @@ -1099,7 +1099,9 @@ private void process() {
dest.append(info);
info = "";
} else {
dest.append(info, 0, nl);
// append up to the newline (ignoring \r if present)
dest.append(info, 0,
(nl > 0 && info.charAt(nl - 1) == '\r') ? nl - 1 : nl);
info = info.substring(nl + 1);
}
}
Expand Down

1 comment on commit 38159d5

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 38159d5 Oct 7, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.