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-io.git
commit 5b2cf0d7409e3b811e828e85c320f8687bd8b0e5 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Feb 9 18:04:17 2024 -0500 [IO-405] Handle zero and negative thresholds #587 Simplify --- src/changes/changes.xml | 1 + .../java/org/apache/commons/io/output/ThresholdingOutputStream.java | 4 +--- .../org/apache/commons/io/output/ThresholdingOutputStreamTest.java | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d61295ea3..6291db662 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -106,6 +106,7 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ggregory" type="fix" issue="IO-845" due-to="Elliotte Rusty Harold">Test links to targets outside the source directory #571.</action> <action dev="ggregory" type="fix" due-to="Elliotte Rusty Harold">Focus Javadoc on current version rather than past versions #573, #574.</action> <action dev="ggregory" type="fix" issue="IO-469" due-to="Grigory Fadeev, Kristian Rosenvold, Elliotte Rusty Harold">"Self-suppression not permitted" while using BrokenOutput and BrokenInput streams with try-with-resources.</action> + <action dev="ggregory" type="fix" issue="IO-405" due-to="Elliotte Rusty Harold">Handle zero and negative thresholds #587.</action> <!-- Add --> <action dev="ggregory" type="add" due-to="Gary Gregory">Add and use PathUtils.getFileName(Path, Function<Path, R>).</action> <action dev="ggregory" type="add" due-to="Gary Gregory">Add and use PathUtils.getFileNameString().</action> diff --git a/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java b/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java index e5b8d5a0b..fd7a8614f 100644 --- a/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java @@ -92,9 +92,7 @@ public class ThresholdingOutputStream extends OutputStream { this.threshold = threshold; this.thresholdConsumer = thresholdConsumer == null ? IOConsumer.noop() : thresholdConsumer; this.outputStreamGetter = outputStreamGetter == null ? NOOP_OS_GETTER : outputStreamGetter; - if (threshold < 0) { - thresholdExceeded = true; - } + this.thresholdExceeded = threshold < 0; } /** diff --git a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java index efa67b4f1..f69f22c0e 100644 --- a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java @@ -57,7 +57,7 @@ public class ThresholdingOutputStreamTest { @Test public void testSetByteCount_OutputStream() throws Exception { - final AtomicBoolean reached = new AtomicBoolean(false); + final AtomicBoolean reached = new AtomicBoolean(); try (ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { { setByteCount(2); @@ -82,7 +82,7 @@ public class ThresholdingOutputStreamTest { @Test public void testSetByteCount_Stream() throws Exception { - final AtomicBoolean reached = new AtomicBoolean(false); + final AtomicBoolean reached = new AtomicBoolean(); try (ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { { setByteCount(2);