Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333767

Summary: XMLSourceFromInputStream trim input data
Product: [Tools] Data Tools Reporter: Břetislav Če ník <B.Cernik>
Component: Enablement:ODAAssignee: Mingxia Wu <mwu>
Status: NEW --- QA Contact: Xiaoying Gu <bluesoldier>
Severity: normal    
Priority: P3 CC: bin.feng, bluesoldier, lchan
Version: 1.8.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Břetislav Če ník CLA 2011-01-07 11:56:03 EST
There are bad implementation of reading data in the class
org.eclipse.datatools.enablement.oda.xml.util.XMLSourceFromInputStream.LocalCache

on construtor LocalCache( InputStream in )

The constructor read data from InputStream to local memory variable cacheMem but on some platform - Tomcat on windows x64 it doesn't read all data but only first available block/packet.

public LocalCache( InputStream in ) throws OdaException
{
	assert in != null;
	try
	{
		memSize = in.read( cacheMem ); 
// !!! there is bug. It doesn't read data to end of stream or cacheMem.length. 
// It read only a few first kB from InputStream
		if ( memSize == MAX_MEMORY_CACHE_SIZE )
		{
.
.
.


Method read of InputStream class read only available data not all data to end of file. Result is that the xml data are trimmed.

I get this trouble in Tomcat 7 x64 Winddows 2008 x64 platform in HttpServlet that call Birt with setting "org.eclipse.datatools.enablement.oda.xml.inputStream" appContext property
Comment 1 Bin Feng CLA 2011-02-21 04:14:28 EST
The behavior of InputStream.read() is determined by the underlying implementation. There is little information about the InputStream being used for producing the problem. Could you provide more detailed info required for reproduced the problem?
Comment 2 Břetislav Če ník CLA 2011-02-22 13:03:56 EST
In Java API Specification for Inputstream method 
public int read(byte[] b)
         throws IOException

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input !!! data is available !!!, end of file is detected, or an exception is thrown. 

By the API specification one read method doesn't need to read all data of InputStream to EOF. 
If no data is available ie. reading from HttpServletRequest.getInputStream() method return control and next data will be available after some time.