[
https://issues.apache.org/jira/browse/ODFTOOLKIT-377?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13765592#comment-13765592
]
Svante Schubert commented on ODFTOOLKIT-377:
--------------------------------------------
I tested it on the the latest sources, just used the LoadSaveTest and created a
3.8 ods, which had 79MB of content.xml.
The test hangs or takes for ages.
The good news, I tested it on my branch and it works.
So I have done a fix in the past or the current release has some broken feature.
No time to merge now, but I looked over OdfPackage and I would start to
exchange the existing multi-threaded getInputStream
/**
* Gets the InputStream containing whole OdfPackage.
*
* @return the ODF package as input stream
* @throws java.lang.Exception
* - if the package could not be read
*/
public InputStream getInputStream() throws Exception {
final PipedOutputStream os = new PipedOutputStream();
final PipedInputStream is = new PipedInputStream();
is.connect(os);
Thread thread1 = new Thread() {
@Override
public void run() {
try {
save(os, mBaseURI);
} catch (Exception e) {
}
}
};
Thread thread2 = new Thread() {
@Override
public void run() {
try {
BufferedInputStream bis = new
BufferedInputStream(is, StreamHelper.PAGE_SIZE);
BufferedOutputStream bos = new
BufferedOutputStream(os, StreamHelper.PAGE_SIZE);
StreamHelper.transformStream(bis, bos);
is.close();
os.close();
} catch (Exception ie) {
}
}
};
thread1.start();
thread2.start();
return is;
}
With the safer following way:
/**
* Gets the InputStream containing whole OdfPackage.
*
* @return the ODF package as input stream
* @throws java.io.IOException
* - if the package could not be read
*/
public InputStream getInputStream() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
save(out, mBaseURI);
return new ByteArrayInputStream(out.toByteArray());
}
Hope that helps!
Svante
> Error writing large .ods files (3 MB)
> -------------------------------------
>
> Key: ODFTOOLKIT-377
> URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-377
> Project: ODF Toolkit
> Issue Type: Bug
> Components: java, odfdom, performance, simple api
> Affects Versions: 0.5-incubating
> Environment: Windows 7, java 1.7
> Reporter: Jacinto Verdaguer
> Labels: patch, performance
> Fix For: 0.5-incubating
>
>
> I'm modifying file metadata .ods, the application works correctly for files
> under 3 MB but in the case of files larger of 2,8 MB it creates a file 2 KB
> and get locked by the java process. No java error display.
> My code is as follows:
> doc = OdfDocument.loadDocument(new File("C:\tmp\ficheroIn.ods"));
> OdfFileDom metadom = doc.getMetaDom();
> Meta metadata = new Meta(metadom);
> metadata.setTitle(plantilla.getTitulo());
> metadata.setSubject(plantilla.getAsunto());
> metadata.setCreator(plantilla.getModificadoPor());
> metadata.setDescription(plantilla.getComentarios());
> doc.save("C:\tmp\ficheroOut.ods");
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira