commit | f76ee129d348f04c540d205856853e587ae22766 | [log] [tgz] |
---|---|---|
author | Piotr P. Karwasz <pkarwasz-github@apache.org> | Fri Oct 17 15:23:57 2025 +0200 |
committer | GitHub <noreply@github.com> | Fri Oct 17 09:23:57 2025 -0400 |
tree | 8b7378d1f0dbcf9c5b3fa3dbe5eb8b200238f05d | |
parent | 3c5166e34e19efe35b522badd08e5e7960d9c49e [diff] |
Fix concurrency issue in `IOUtils.skip` (#801) * Fix concurrency issue in `IOUtils.skip` This patch addresses a concurrency problem in `IOUtils.skip`, as reported in [COMPRESS-666](https://issues.apache.org/jira/browse/COMPRESS-666) and [COMPRESS-697](https://issues.apache.org/jira/browse/COMPRESS-697). Previously, `IOUtils.skip` relied on `InputStream#read` to skip bytes, using a buffer shared across **all** threads. Although `IOUtils.skip` itself does not consume the data read, certain `InputStream` implementations (e.g. `ChecksumInputStream`) may process that data internally. In concurrent scenarios, this shared buffer could be overwritten by another thread between the `read` and the subsequent internal processing (such as checksum calculation), leading to incorrect behavior. This change reverts commit c12eaff7f747353a7a9a97df735fd3301f42e313 and restores the use of a **per-thread buffer** in `IOUtils.skip`, ensuring thread safety and correct behavior in concurrent environments. * Adds a reentrancy guard to the thread-local pool * Apply suggestion from @Copilot (1) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestions from @Copilot (2) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more.
More information can be found on the Apache Commons IO homepage. The Javadoc can be browsed. Questions related to the usage of Apache Commons IO should be posted to the user mailing list.
You can download source and binaries from our download page.
Alternatively, you can pull it from the central Maven repositories:
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.20.0</version> </dependency>
Building requires a Java JDK and Apache Maven. The required Java version is found in the pom.xml
as the maven.compiler.source
property.
From a command shell, run mvn
without arguments to invoke the default Maven goal to run all tests and checks.
We accept Pull Requests via GitHub. The developer mailing list is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us:
mvn
.mvn
(by itself), this runs the default goal, which contains all build checks.mvn clean site -Dcommons.jacoco.haltOnFailure=false -Pjacoco
If you plan to contribute on a regular basis, please consider filing a contributor license agreement. You can learn more about contributing via GitHub in our contribution guidelines.
This code is licensed under the Apache License v2.
See the NOTICE.txt
file for required notices and attributions.
You like Apache Commons IO? Then donate back to the ASF to support development.
Please see the list of components