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

Tagged input and output streams

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.0
    • Streams/Writers
    • None

    Description

      I'd like to introduce two new proxy streams, TaggedInputStream and TaggedOutputStream, that tag all exceptions thrown by the proxied streams. The goal is to make it easier to detect the source of an IOException when you're dealing with multiple different streams. For example:

      InputStream input = ...;
      OutputStream output = ...;
      TaggedOutputStream proxy = new TaggedOutputStream(output);
      try {
          IOUtils.copy(input, proxy);
      } catch (IOException e) {
          if (proxy.isTagged(e)) {
              // Could not write to the output stream
              // Perhaps we can handle that error somehow (retry, cancel?)
              e.initCause(); // gives the original exception from the proxied stream
          } else {
              // Could not read from the input stream, nothing we can do
              throw e;
          }
      }
      

      I'm working on a patch to implement such a feature.

      Attachments

        1. IO-192-tagged-stream-changes.patch
          31 kB
          Niall Pemberton
        2. IO-192.patch
          9 kB
          Jukka Zitting

        Issue Links

          Activity

            People

              jukkaz Jukka Zitting
              jukkaz Jukka Zitting
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: