[ 
https://issues.apache.org/jira/browse/IO-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17800172#comment-17800172
 ] 

Elliotte Rusty Harold commented on IO-405:
------------------------------------------

I don't see any reason for the constructor to throw an exception. Looking at 
the code I do notice that it doesn't really document or test what happens when 
the threshold is less than one, though I think the first byte written probably 
does throw an exception. I'll need to add a test for that.

> Support threshold=0 in ThresholdingOutputStream
> -----------------------------------------------
>
>                 Key: IO-405
>                 URL: https://issues.apache.org/jira/browse/IO-405
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 2.5
>            Reporter: Jochen Wiedmann
>            Assignee: Jochen Wiedmann
>            Priority: Minor
>
> I recently had a case where I would wish threshold=0 to trigger an immediate 
> thresholdReached() in ThresholdingOutputStream(). This seems to me to be a 
> natural expectation. However, thresholdReached() is only triggered after the 
> first byte has been written.
> I'd like to modify the constructor of ThresholdingOutputStream() in that 
> sense. However, as thresholdReached() might throw an IOException, there are 
> two possibilities I'd like to discuss:
> 1.) Pass the IOException through. Or, in other words: Modify the constructor 
> to throw an IOException. (Slight binary incompatibility.)
> 2.) Catch the IOException, pass on a RuntimeException. Source code 
> compatibility, but surprising for the developer.
> Personally, I'm in favour for 1.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to