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

Gary D. Gregory commented on IO-868:
------------------------------------

Hello [~reschke] and thank you for the feedback.

I improved the Javadoc in git master as follows:

{code:java}
        /**
         * Builds a new {@link BoundedInputStream}.
         * <p>
         * You must set an aspect that supports {@link #getInputStream()}, 
otherwise, this method throws an exception.
         * </p>
         * <p>
         * If you start from an input stream, an exception can't be thrown, and 
you can call {@link #getUnchecked()} instead.
         * </p>
         * <p>
         * This builder uses the following aspects:
         * </p>
         * <ul>
         * <li>{@link #getInputStream()} (the target aspect)</li>
         * <li>{@link #getAfterRead()}</li>
         * <li>{@link #getCount()}</li>
         * <li>{@link #getMaxCount()}</li>
         * <li>{@link #getOnMaxCount()}</li>
         * <li>{@link #isPropagateClose()}</li>
         * </ul>
         *
         * @return a new instance.
         * @throws IllegalStateException         if the {@code origin} is 
{@code null}.
         * @throws UnsupportedOperationException if the origin cannot be 
converted to an {@link InputStream}.
         * @throws IOException                   if an I/O error occurs 
converting to an {@link InputStream} using {@link #getInputStream()}.
         * @see #getInputStream()
         * @see #getUnchecked()
         */
        @Override
        public BoundedInputStream get() throws IOException
{code}

Would you please review and indicate if you can think of improvements?

After that, I can make similar changes to other get() methods.
 

> BoundedInputStream builder() can throw IOException
> --------------------------------------------------
>
>                 Key: IO-868
>                 URL: https://issues.apache.org/jira/browse/IO-868
>             Project: Commons IO
>          Issue Type: Wish
>          Components: Streams/Writers
>            Reporter: Julian Reschke
>            Priority: Major
>
> See
>   
> https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/input/BoundedInputStream.Builder.html#get()
> This proved to be problematic when removing Guava usage from a project. 
> Guava's constructor for CountingInputStream doesn't declare a checked 
> exception, nor do the constructors of commons-io's CountingInputStream or 
> BoundedInputStream.
> Using the recommended builder however does in the "get()" method. Why?
> This makes it harder to convert existing code that does not expect an 
> exception here. What is the recommendation? Catch and wrap into a 
> RuntimeException?
> Minimally it would good if the Javadoc explained under which condition the 
> IOException could occur.



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

Reply via email to