Hi,
I'm new to this mailing list, I've checked if anyone experienced my
problem and I was unable to find this in bugzilla.
I'm using POI 1.5.1 with embedded xsl files in a Jar file.
While retrieving a HSSFWorkbook providing an InputStream with a
getClass().getClassLoader().getResourceAsStream(..), we experienced an
IOException with
the following configuration :
* Linux Mandrake
* Sun JDK 1.3.1_06
* With Resin 2.1.5 as a servlet engine.
The IOException is :
java.io.IOException
Unable to read entire block; 389 bytes read; expected 512 bytes
java.io.IOException: Unable to read entire block; 389 bytes read;
expected 512 bytes
at
org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98)
at
org.apache.poi.poifs.storage.RawDataBlockList.<init>(RawDataBlockList.ja
va:88)
at
org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.j
ava:123)
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:175)
[catch] at
com.sharedvalue.as360.export.jobExport.export(jobExport.java:504)
at
com.sharedvalue.as360.export.jobExport.startJob(jobExport.java:114)
(The file in the Jar file are correct and the file size is a multiple of
512 bytes).
While reading RawDataBlock.java file, the InputStream is read with a
stream.read(). But the specification allow an InputStream to return only
a part of a block
(http://java.sun.com/j2se/1.3/docs/api/java/io/InputStream.html#read())
and it seems to be the case for me.
So I patch this file as following :
public RawDataBlock(final InputStream stream)
throws IOException
{
_data = new byte[ POIFSConstants.BIG_BLOCK_SIZE ];
int count = 0;
int totalBytesRead = 0;
while ((totalBytesRead < POIFSConstants.BIG_BLOCK_SIZE) &&
(count != -1)) {
count = stream.read(_data, totalBytesRead,
POIFSConstants.BIG_BLOCK_SIZE - totalBytesRead);
if (count != -1) {
totalBytesRead += count;
}
}
if (count == -1) {
_eof = true;
} else {
_eof = false;
}
if ((totalBytesRead != POIFSConstants.BIG_BLOCK_SIZE) &&
(totalBytesRead != 0)) {
String type = " byte" + ((totalBytesRead == 1) ? ("")
: ("s"));
throw new IOException("Unable to read entire block; " +
totalBytesRead
+ type + " read; expected "
+ POIFSConstants.BIG_BLOCK_SIZE + "
bytes");
}
}
This works for me. Does this seems good ?
If so, I can open a bug in Bugzilla and provide a patch file.
Thanks,
-Eric
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>