Copilot commented on code in PR #775:
URL: https://github.com/apache/commons-compress/pull/775#discussion_r3551399080
##########
src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java:
##########
@@ -109,6 +109,16 @@ private static Map<String, String> parsePaxHeaders(final
byte[] data, final List
return TarUtils.parsePaxHeaders(new ByteArrayInputStream(data),
globalPaxHeaders, data.length, Short.MAX_VALUE, sparseHeaders);
}
+ private static byte[] pax1xSparseHeaderAlignedToSingleRecord() {
+ final StringBuilder header = new StringBuilder("100\n");
+ for (int i = 0; i < 200; i++) {
+ header.append(i < 108 ? "00\n" : "0\n");
+ }
+ final byte[] bytes = header.toString().getBytes(UTF_8);
+ assertEquals(512, bytes.length);
+ return bytes;
+ }
Review Comment:
This helper relies on the hard-coded threshold `i < 108` to make the
sparse-header bytes land exactly on a 512-byte boundary. That magic number is
non-obvious and brittle if the entry count or record size ever changes; it
would be clearer to derive the number of extra digits needed from `recordSize`
and the chosen sparse entry count.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]