ppkarwasz commented on code in PR #754:
URL: https://github.com/apache/commons-compress/pull/754#discussion_r2614005312
##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -756,12 +756,8 @@ private ZipFile(final Builder builder) throws IOException {
}
fillNameMap();
} catch (final IOException e) {
- final ArchiveException archiveException = e instanceof
ArchiveException
- ? (ArchiveException) e
- : new ArchiveException("Error reading Zip content from " +
builder.getName(), (Throwable) e);
this.closed = true;
- IOUtils.close(archive, archiveException::addSuppressed);
- throw archiveException;
+ throw IOUtils.closeQuietly(archive, e);
}
Review Comment:
Same as above: I wouldn't rely on an unpublished IO method and use what is
available now.
```java
} catch (final Exception e) {
this.closed = true;
final IOException ioe = e instanceof IOException ? (IOException)
e : new ArchiveException(e);
IOUtils.closeQuietly(archive, ioe::addSuppressed);
throw ioe;
}
```
##########
src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java:
##########
@@ -629,9 +629,7 @@ private SevenZFile(final Builder builder) throws
IOException {
archive = readHeaders(password);
this.password = password != null ? Arrays.copyOf(password,
password.length) : null;
} catch (final ArithmeticException | IllegalArgumentException e) {
- final ArchiveException archiveException = new ArchiveException(e);
- IOUtils.close(channel, archiveException::addSuppressed);
- throw archiveException;
+ throw IOUtils.closeQuietly(channel, new ArchiveException(e));
}
Review Comment:
Honestly, I wouldn't delay the release of `commons-compress` version
`1.29.0` more than it already has been to wait for a new version of
`commons-io`.
Let's use what we have in `2.21.0`:
```java
} catch (final Exception e) {
final IOException ioe = e instanceof IOException ? (IOException)
e : new ArchiveException(e);
IOUtils.closeQuietly(channel, ioe::addSuppressed);
throw ioe;
}
```
When we **do** release Commons IO version `2.22.0`, we'll update this call
site and **all** the other call sites that might benefit from the new method.
There is no chance to forget that, since `closeQuietly` becomes ambiguous in IO
`2.22.0`.
--
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]