[
https://issues.apache.org/jira/browse/IO-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673492#action_12673492
]
jukkaz edited comment on IO-192 at 2/14/09 2:06 AM:
-----------------------------------------------------------
My point about the static IOUtils methods is that IMHO using the tagged stream
features across method calls is bad form. Consider the following alternative to
the bar() method:
{code}
public void bar(InputStream input, OutputStream output) {
TaggedInputStream taggedInput = new TaggedInputStream(input);
TaggedOutputStream taggedOutput = new TaggedOutputStream(output);
try {
processStreams(taggedInput, taggedOutput);
} catch (IOException e) {
if (taggedInput.isCauseOf(e)) {
....
}
if (taggedOutput.isCauseOf(e)) {
....
}
}
}
{code}
There is no need for a caller to know that bar() needs the tagged stream
functionality. That can (and should) be encapsulated within bar(). Thus I think
it's better if we *don't* provide the static IOUtils methods, as that'll make
it harder for people to write bad APIs that silently assume extra functionality
on stream instances.
was (Author: jukkaz):
My point about the static IOUtils methods is that IMHO using the tagged
stream features across method calls is bad form. Consider the following
alternative to the bar() method:
{code}
public void bar(InputStream input, OutputStream output) {
TaggedInputStream taggedInput = new TaggedInputStream(input);
TaggedInputStream taggedOutput = new TaggedInputStream(output);
try {
processStreams(taggedInput, taggedOutput);
} catch (IOException e) {
if (taggedInput.isCauseOf(e)) {
....
}
if (taggedOutput.isCauseOf(e)) {
....
}
}
}
{code}
There is no need for a caller to know that bar() needs the tagged stream
functionality. That can (and should) be encapsulated within bar(). Thus I think
it's better if we *don't* provide the static IOUtils methods, as that'll make
it harder for people to write bad APIs that silently assume extra functionality
on stream instances.
> 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.