[shrinkwrap-issues] [JBoss JIRA] (SHRINKDESC-153) XmlDomNodeImporterImpl should never rely on InputStream.available()

George Gastaldi (JIRA) jira-events at lists.jboss.org
Wed Oct 23 14:04:02 EDT 2013


    [ https://issues.jboss.org/browse/SHRINKDESC-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12824390#comment-12824390 ] 

George Gastaldi edited comment on SHRINKDESC-153 at 10/23/13 2:02 PM:
----------------------------------------------------------------------

Ralf,
I believe the best solution is to remove the if statement and the consumer of the InputStream should handle this.
                
      was (Author: gastaldi):
    Ralf,
A SocketInputStream may not return the available() bytes.
The best solution is to remove the if statement. Let the consumer of the InputStream handle this
                  
> XmlDomNodeImporterImpl should never rely on InputStream.available()
> -------------------------------------------------------------------
>
>                 Key: SHRINKDESC-153
>                 URL: https://issues.jboss.org/browse/SHRINKDESC-153
>             Project: ShrinkWrap Descriptors
>          Issue Type: Bug
>          Components: spi
>            Reporter: George Gastaldi
>            Assignee: Ralf Battenfeld
>
> Some InputStream implementations return 0 in the available() method, however it is possible to read. This is described in the javadoc: 
> {quote}
> Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might 
>  be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. 
> Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer 
>  intended to hold all data in this stream. 
> {quote}
> The problematic code lies in 
> https://github.com/shrinkwrap/descriptors/blob/master/spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/dom/XmlDomNodeImporterImpl.java#L58

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the shrinkwrap-issues mailing list