Allowing ThesholdingOuputStream to reset written and thresholdExceeded values?
------------------------------------------------------------------------------

                 Key: IO-121
                 URL: https://issues.apache.org/jira/browse/IO-121
             Project: Commons IO
          Issue Type: Improvement
          Components: Streams/Writers
    Affects Versions: 1.3
         Environment: Any
            Reporter: Tom Nichols
            Priority: Trivial
         Attachments: ThresholdingOutputStream.java, TOS-reset.patch

please add a protected reset() method to ThresholdingOutputStream that will 
reset the byteCount and thresholdExceeded values:
        protected void reset() 
        {
                this.thresholdExceeded = false;
                this.written = 0;
        }


The order of operations for the base checkThreshold(int) method will need to be 
changed to allow reset() to be properly called from thresholdReached():
    protected void checkThreshold(int count) throws IOException
    {
        if (!thresholdExceeded && (written + count > threshold))
        {
            thresholdExceeded = true;
            thresholdReached();  //call comes _after_ thresholdExceeded = true.
        }
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to