Uploaded image for project: 'ShrinkWrap Descriptors'
  1. ShrinkWrap Descriptors
  2. SHRINKDESC-153

XmlDomNodeImporterImpl should never rely on InputStream.available()

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: spi
    • Labels:
      None

      Description

      Some InputStream implementations return 0 in the available() method, however it is possible to read. This is described in the javadoc:

      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.

      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

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                rbattenfeld Ralf Battenfeld
                Reporter:
                gastaldi George Gastaldi
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: