This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch commons_io_2_21_0
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/commons_io_2_21_0 by this push:
new c4de710a3 Migrate to Apache Commons IO 2.21.0-SNAPSHOT
c4de710a3 is described below
commit c4de710a3b01fe6a21b981c9396ff8fd85344974
Author: Gary D. Gregory <[email protected]>
AuthorDate: Wed Oct 1 17:51:54 2025 -0400
Migrate to Apache Commons IO 2.21.0-SNAPSHOT
---
pom.xml | 13 ++++++++++++-
.../commons/compress/archivers/sevenz/SevenZFile.java | 17 +++++++++--------
.../apache/commons/compress/archivers/zip/ZipFile.java | 17 +++++++++--------
.../commons/compress/archivers/zip/Zip64SupportIT.java | 2 ++
4 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/pom.xml b/pom.xml
index 498a0d52d..b6e8fe7fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,6 +90,17 @@ Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
<checkstyle.suppress.file>${basedir}/src/conf/checkstyle/checkstyle-suppressions.xml</checkstyle.suppress.file>
<checkstyle.resourceExcludes>LICENSE.txt, NOTICE.txt,
**/maven-archiver/pom.properties</checkstyle.resourceExcludes>
</properties>
+ <repositories>
+ <!-- TEMP for branch commons_io... -->
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/COMPRESS</url>
@@ -203,7 +214,7 @@ Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z,
arj.
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.20.0</version>
+ <version>2.21.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git
a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 28dfddb27..c75544f2a 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -54,8 +54,8 @@
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.compress.utils.InputStreamStatistics;
-import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
import org.apache.commons.io.build.AbstractOrigin.ByteArrayOrigin;
+import org.apache.commons.io.build.AbstractOrigin.ChannelOrigin;
import org.apache.commons.io.build.AbstractStreamBuilder;
import org.apache.commons.io.input.BoundedInputStream;
import org.apache.commons.io.input.ChecksumInputStream;
@@ -184,7 +184,6 @@ public static class Builder extends
AbstractStreamBuilder<SevenZFile, Builder> {
static final boolean USE_DEFAULTNAME_FOR_UNNAMED_ENTRIES = false;
static final boolean TRY_TO_RECOVER_BROKEN_ARCHIVES = false;
- private SeekableByteChannel seekableByteChannel;
private String defaultName = DEFAULT_FILE_NAME;
private byte[] password;
private int maxMemoryLimitKiB = MEMORY_LIMIT_KIB;
@@ -201,11 +200,14 @@ public static class Builder extends
AbstractStreamBuilder<SevenZFile, Builder> {
public SevenZFile get() throws IOException {
final SeekableByteChannel actualChannel;
final String actualDescription;
- if (seekableByteChannel != null) {
- actualChannel = seekableByteChannel;
+ final boolean isChannelOrigin = checkOrigin() instanceof
ChannelOrigin;
+ boolean isSeekableByteChannellOrigin = false;
+ if (isChannelOrigin) {
+ actualChannel = getChannel(SeekableByteChannel.class);
+ isSeekableByteChannellOrigin = true;
actualDescription = defaultName;
} else if (checkOrigin() instanceof ByteArrayOrigin) {
- actualChannel = new
SeekableInMemoryByteChannel(checkOrigin().getByteArray());
+ actualChannel = getChannel(SeekableByteChannel.class);
actualDescription = defaultName;
} else {
OpenOption[] openOptions = getOpenOptions();
@@ -216,7 +218,7 @@ public SevenZFile get() throws IOException {
actualChannel = Files.newByteChannel(path, openOptions);
actualDescription = path.toAbsolutePath().toString();
}
- final boolean closeOnError = seekableByteChannel != null;
+ final boolean closeOnError = isSeekableByteChannellOrigin;
return new SevenZFile(actualChannel, actualDescription, password,
closeOnError, maxMemoryLimitKiB, useDefaultNameForUnnamedEntries,
tryToRecoverBrokenArchives);
}
@@ -301,8 +303,7 @@ public Builder setPassword(final String password) {
* @return {@code this} instance.
*/
public Builder setSeekableByteChannel(final SeekableByteChannel
seekableByteChannel) {
- this.seekableByteChannel = seekableByteChannel;
- return this;
+ return setChannel(seekableByteChannel);
}
/**
diff --git
a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 3e28361c3..fc2a90b33 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -61,10 +61,10 @@
import org.apache.commons.compress.utils.BoundedSeekableByteChannelInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.compress.utils.InputStreamStatistics;
-import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.build.AbstractOrigin.ByteArrayOrigin;
+import org.apache.commons.io.build.AbstractOrigin.ChannelOrigin;
import org.apache.commons.io.build.AbstractStreamBuilder;
import org.apache.commons.io.function.IOFunction;
import org.apache.commons.io.function.IOStream;
@@ -135,7 +135,6 @@ protected int read(final long pos, final ByteBuffer buf)
throws IOException {
public static class Builder extends AbstractStreamBuilder<ZipFile,
Builder> {
static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
- private SeekableByteChannel seekableByteChannel;
private boolean useUnicodeExtraFields = true;
private boolean ignoreLocalFileHeader;
private long maxNumberOfDisks = 1;
@@ -153,11 +152,14 @@ public Builder() {
public ZipFile get() throws IOException {
final SeekableByteChannel actualChannel;
final String actualDescription;
- if (seekableByteChannel != null) {
- actualChannel = seekableByteChannel;
+ final boolean isChannelOrigin = checkOrigin() instanceof
ChannelOrigin;
+ boolean isSeekableByteChannellOrigin = false;
+ if (isChannelOrigin) {
+ actualChannel = getChannel(SeekableByteChannel.class);
+ isSeekableByteChannellOrigin = true;
actualDescription = actualChannel.getClass().getSimpleName();
} else if (checkOrigin() instanceof ByteArrayOrigin) {
- actualChannel = new
SeekableInMemoryByteChannel(checkOrigin().getByteArray());
+ actualChannel = getChannel(SeekableByteChannel.class);
actualDescription = actualChannel.getClass().getSimpleName();
} else {
OpenOption[] openOptions = getOpenOptions();
@@ -168,7 +170,7 @@ public ZipFile get() throws IOException {
actualChannel = openZipChannel(path, maxNumberOfDisks,
openOptions);
actualDescription = path.toString();
}
- final boolean closeOnError = seekableByteChannel != null;
+ final boolean closeOnError = isSeekableByteChannellOrigin;
return new ZipFile(actualChannel, actualDescription, getCharset(),
useUnicodeExtraFields, closeOnError, ignoreLocalFileHeader,
zstdInputStreamFactory);
}
@@ -202,8 +204,7 @@ public Builder setMaxNumberOfDisks(final long
maxNumberOfDisks) {
* @return {@code this} instance.
*/
public Builder setSeekableByteChannel(final SeekableByteChannel
seekableByteChannel) {
- this.seekableByteChannel = seekableByteChannel;
- return this;
+ return setChannel(seekableByteChannel);
}
/**
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
index 6804f76a0..9911b6b52 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
@@ -43,6 +43,7 @@
import org.apache.commons.compress.AbstractTest;
import org.apache.commons.io.RandomAccessFileMode;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import shaded.org.apache.commons.io.IOUtils;
@@ -50,6 +51,7 @@
/**
* Tests {@link ZipFile} Zip64 support.
*/
+@Disabled
public class Zip64SupportIT {
interface ZipOutputTest {