Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 71581 invoked from network); 14 Feb 2009 03:11:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Feb 2009 03:11:24 -0000 Received: (qmail 64272 invoked by uid 500); 14 Feb 2009 03:11:23 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 64213 invoked by uid 500); 14 Feb 2009 03:11:23 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 64202 invoked by uid 99); 14 Feb 2009 03:11:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2009 19:11:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2009 03:11:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C241C234C48C for ; Fri, 13 Feb 2009 19:10:59 -0800 (PST) Message-ID: <1485948077.1234581059794.JavaMail.jira@brutus> Date: Fri, 13 Feb 2009 19:10:59 -0800 (PST) From: "Niall Pemberton (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (IO-192) Tagged input and output streams In-Reply-To: <1248016637.1232984279670.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/IO-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673460#action_12673460 ] Niall Pemberton commented on IO-192: ------------------------------------ I have changed the exception handling methods to not return anything and committed them - see IO-195 I still don't think having those instance methods on the tagged streams is a good idea - heres a couple of simple use cases demonstrating my point about polluting/casting: {code} .... TaggedInputStream taggedInput = new TaggedInputStream(input); TaggedOutputStream taggedOutput = new TaggedOutputStream(output); bar(taggedInput, taggedOutput); .... public void bar(TaggedInputStream input, TaggedOutputStream output) { try { input.read(); } catch (IOException e) { if (input.isCauseOf(e)) { .... } if (output.isCauseOf(e)) { .... } } } {code} {code} .... InputStream taggedInput = new TaggedInputStream(input); OutputStream taggedOutput = new TaggedOutputStream(output); bar(taggedInput, taggedOutput); .... public void bar(InputStream input, OutputStream output) { try { input.read(); } catch (IOException e) { if (input instanceof TaggedInputStream && ((TaggedInputStream)input).isCauseOf(e)) { .... } if (output instanceof TaggedOutputStream && ((TaggedOutputStream)output).isCauseOf(e)) { .... } } } {code} IO like other commons components provides building blocks for people to reuse - so currently this is just about your requirement for tagging streams. My thinking is that if someone else wants to tag IO exceptions in other scenarios then its better to provide something that isn't tied to these tagged stream implementations. > Tagged input and output streams > ------------------------------- > > Key: IO-192 > URL: https://issues.apache.org/jira/browse/IO-192 > Project: Commons IO > Issue Type: New Feature > Components: Streams/Writers > Reporter: Jukka Zitting > Assignee: Jukka Zitting > Priority: Minor > Fix For: 1.5 > > Attachments: IO-192-tagged-stream-changes.patch, IO-192.patch > > > 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: > {code} > 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; > } > } > {code} > I'm working on a patch to implement such a feature. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.