Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-121

Allowing ThesholdingOuputStream to reset written and thresholdExceeded values?

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Component/s: Streams/Writers
    • Labels:
      None
    • Environment:

      Any

      Description

      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. }

      }

        Attachments

        1. ThresholdingOutputStream.java
          7 kB
          Tom Nichols
        2. TOS-reset.patch
          0.7 kB
          Tom Nichols

          Activity

            People

            • Assignee:
              niallp Niall Pemberton
              Reporter:
              tomstrummer Tom Nichols
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: