[IO-405] Handle zero and negative thresholds #587
Simplify
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d61295e..6291db6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -106,6 +106,7 @@
<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 e5b8d5a..fd7a861 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 @@
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 efa67b4..f69f22c 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 @@
@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 @@
@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);