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

Allowing ThesholdingOuputStream to reset written and thresholdExceeded values?

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.3
    • 1.4
    • Streams/Writers
    • None
    • 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. TOS-reset.patch
          0.7 kB
          Tom Nichols
        2. ThresholdingOutputStream.java
          7 kB
          Tom Nichols

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: