You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/05/24 16:52:50 UTC
(commons-compress) 02/02: Sort members
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit f4a8dd71be9c9f2cd642f3eeb4368479c48e26cf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 24 12:47:40 2024 -0400
Sort members
---
.../commons/compress/compressors/bzip2/CRC.java | 10 +++---
.../archivers/ArchiveStreamFactoryTest.java | 40 +++++++++++-----------
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
index 2b2e7c1b2..93dcdbdf1 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
@@ -56,6 +56,11 @@ final class CRC {
reset();
}
+ private int compute(final int baseCrc, final int inCh) {
+ int index = baseCrc >> 24 ^ inCh;
+ return baseCrc << 8 ^ CRC32_TABLE[index < 0 ? index + 256 : index];
+ }
+
int getValue() {
return ~crc;
}
@@ -68,11 +73,6 @@ final class CRC {
crc = compute(crc, inCh);
}
- private int compute(final int baseCrc, final int inCh) {
- int index = baseCrc >> 24 ^ inCh;
- return baseCrc << 8 ^ CRC32_TABLE[index < 0 ? index + 256 : index];
- }
-
void update(final int inCh, int repeat) {
int globalCrcShadow = this.crc;
while (repeat-- > 0) {
diff --git a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
index bd4edb84c..3cfb6c30c 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
@@ -283,26 +283,6 @@ public class ArchiveStreamFactoryTest extends AbstractTest {
assertEquals("IOException while reading signature.", e3.getMessage());
}
- /**
- * Test case for <a href="https://issues.apache.org/jira/browse/COMPRESS-674" >COMPRESS-674</a>.
- */
- @Test
- void testUtf16TextIsNotTAR() {
- final ArchiveException archiveException = assertThrows(ArchiveException.class,
- () -> detect("utf16-text.txt"));
- assertEquals("No Archiver found for the stream signature", archiveException.getMessage());
- }
-
- @Test
- void testTarContainingEmptyDirIsTAR() throws IOException, ArchiveException {
- assertEquals(ArchiveStreamFactory.TAR, detect("emptyDir.tar"));
- }
-
- @Test
- void testTarContainingDirWith1TxtFileIsTAR() throws IOException, ArchiveException {
- assertEquals(ArchiveStreamFactory.TAR, detect("dirWith1TxtFile.tar"));
- }
-
/**
* Test case for <a href="https://issues.apache.org/jira/browse/COMPRESS-267" >COMPRESS-267</a>.
*/
@@ -439,4 +419,24 @@ public class ArchiveStreamFactoryTest extends AbstractTest {
}
}
}
+
+ @Test
+ void testTarContainingDirWith1TxtFileIsTAR() throws IOException, ArchiveException {
+ assertEquals(ArchiveStreamFactory.TAR, detect("dirWith1TxtFile.tar"));
+ }
+
+ @Test
+ void testTarContainingEmptyDirIsTAR() throws IOException, ArchiveException {
+ assertEquals(ArchiveStreamFactory.TAR, detect("emptyDir.tar"));
+ }
+
+ /**
+ * Test case for <a href="https://issues.apache.org/jira/browse/COMPRESS-674" >COMPRESS-674</a>.
+ */
+ @Test
+ void testUtf16TextIsNotTAR() {
+ final ArchiveException archiveException = assertThrows(ArchiveException.class,
+ () -> detect("utf16-text.txt"));
+ assertEquals("No Archiver found for the stream signature", archiveException.getMessage());
+ }
}