You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by xe...@xml.apache.org on 2004/10/01 18:37:31 UTC
[jira] Created: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
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: Unassigned
Priority: Major
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: Fri, 1 Oct 2004 9:36 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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
[jira] Commented: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Posted by xe...@xml.apache.org.
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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
[jira] Resolved: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Posted by xe...@xml.apache.org.
Message:
The following issue has been resolved as INVALID.
Resolver: Michael Glavassevich
Date: Mon, 4 Oct 2004 1:47 PM
As per my previous comment, marking this one as invalid.
---------------------------------------------------------------------
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: Mon, 4 Oct 2004 1:47 PM
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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
[jira] Commented: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Posted by xe...@xml.apache.org.
The following comment has been added to this issue:
Author: larry oneill
Created: Fri, 1 Oct 2004 9:45 AM
Body:
In the load(int offset, boolean changeEntity) method of XMLEntityScanner, line 1740 on, is changed from:
int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset, length);
to
int count = 0;
do {
count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset, length);
if (DEBUG_BUFFER) System.out.println("Buffer read returned a count of " + count);
} while(count == 0 && length != 0);
So that reads are attempted until some bytes or -1 is returned.
---------------------------------------------------------------------
View this comment:
http://issues.apache.org/jira/browse/XERCESJ-1015?page=comments#action_53593
---------------------------------------------------------------------
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: Unassigned
Priority: Major
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: Fri, 1 Oct 2004 9:45 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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
[jira] Updated: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Posted by xe...@xml.apache.org.
The following issue has been updated:
Updater: larry oneill (mailto:loneill7@gmail.com)
Date: Fri, 1 Oct 2004 9:41 AM
Comment:
Usage
java RepeatingParser <xmlFile> <int:iterations <int:failOnIteration> [boolean failAtFileEnd]
If the file is over 2k in size, an ArrayIndexOutOfBoundsException will be shown, as the artificial zero byte read is generated on the second byte array read (after 2048 bytes).
If the 4th arg is 'true' and the XML file ends with a Unix style LF, a SAXParseException will be thrown with one of the two messages mentioned in the description.
Changes:
Attachment changed to RepeatingParser.java
---------------------------------------------------------------------
For a full history of the issue, see:
http://issues.apache.org/jira/browse/XERCESJ-1015?page=history
---------------------------------------------------------------------
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: Unassigned
Priority: Major
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: Fri, 1 Oct 2004 9:41 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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
[jira] Commented: (XERCESJ-1015) Zero byte read on InputStream causes false SAXParseException when LF at end of file
Posted by xe...@xml.apache.org.
The following comment has been added to this issue:
Author: Michael Glavassevich
Created: Sun, 3 Oct 2004 9:43 AM
Body:
The Javadoc for InputStream.read(byte[] b, int off, int len) says:
"...
This method blocks until input data is available, end of file is detected, or an exception is thrown.
If b is null, a NullPointerException is thrown.
If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.
If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
..."
Zero bytes will only be read if the length specified is zero, otherwise at least one byte will be read. When the length parameter is non-zero a *conforming* InputStream must return at least one byte or -1 if the end of the stream has been reached. It sounds like the InputStream you are using is violating this condition and returning 0 instead of -1 at the end of the stream. This is a bug in the InputStream, not the parser. This should be fixed at the source. When the input stream is broken the parser shouldn't be guessing what the stream is trying to tell it.
---------------------------------------------------------------------
View this comment:
http://issues.apache.org/jira/browse/XERCESJ-1015?page=comments#action_53644
---------------------------------------------------------------------
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: Unassigned
Priority: Major
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: Sun, 3 Oct 2004 9:43 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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org