The following comment has been added to this issue:

     Author: larry oneill
    Created: Tue, 5 Oct 2004 5:57 AM
       Body:
Michael Glavassevich makes a fair point that a zero count should never be returned 
from a InputStream read (unless a length of zero was requested). 

I still think there may be some case for a little defensive programming here but 
appreciate that not every potentially erroneous situation can be catered for.
---------------------------------------------------------------------
View this comment:
  http://issues.apache.org/jira/browse/XERCESJ-1015?page=comments#action_53714

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-1015

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-1015
    Summary: Zero byte read on InputStream causes false SAXParseException when LF at 
end of file
       Type: Bug

     Status: Resolved
   Priority: Major
 Resolution: INVALID

    Project: Xerces2-J
 Components: 
             SAX
   Versions:
             2.6.0
             2.6.2

   Assignee: 
   Reporter: larry oneill

    Created: Fri, 1 Oct 2004 9:36 AM
    Updated: Tue, 5 Oct 2004 5:57 AM
Environment: Windows XP, 586

Description:
Under the following circumstances false SAXParseExceptions are thrown.

When a document is being parsed and has reached the end of the document.
If the InputStream supplying the document returns a 0 length indicator (meaning no 
bytes currently available) AND
There is a Line Feed character at the end of the file, after the last element (without 
a carriage return).
Then a false SAXParseException with one of the two following messages is thrown:
"Content is not allowed in trailing section"
or 
"The markup in the document following the root element must be well-formed"

This could happen if the InputStream is reading from a buffer whose writer thread has 
returned a 0 instead of -1 when the buffer is closed. While the writer to the buffer 
should return a -1 on buffer close, in practice this may not always happen and Xerces 
should cater for it.  It certainly should not throw a spurious exception.

If a zero byte count is returned by an InputStream read while reading in the middle of 
the document an ArrayIndexOutOfBounds exception is thrown.

I will include sample code to demonstrate both of these cases and a possible fix for 
the problem.


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to