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 "Winfried Wasser (JIRA)" <xe...@xml.apache.org> on 2005/02/15 08:34:12 UTC
[jira] Commented: (XERCESJ-1037) Critical Object streaming error with large documents
[ http://issues.apache.org/jira/browse/XERCESJ-1037?page=comments#action_59186 ]
Winfried Wasser commented on XERCESJ-1037:
------------------------------------------
Simple testcase for you (and it's not a memory problem).
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import junit.framework.TestCase;
import org.apache.xerces.dom.DocumentImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class TestSerialisation extends TestCase {
public TestSerialisation() {
super();
}
public static void main(String[] args) {
junit.textui.TestRunner.run(TestSerialisation.class);
}
public void test_001() {
Document document = new DocumentImpl();
document.appendChild(document.createElement("childs"));
File outputFile = new File("test.bin");
try {
for (int i = 0; i < 100; i++) {
Element rootElement = document.getDocumentElement();
for (int loop = 0; loop < 50; loop++) {
Element child = (Element) rootElement.appendChild(document.createElement("test"));
child.appendChild(document.createTextNode("NR_" + ((i * 10) + loop + 1)));
}
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outputFile, false));
out.writeObject(document);
out.flush();
out.close();
} catch (Throwable e) {
e.printStackTrace();
fail("Serialisation failed : " + e.getMessage());
}
System.out.println("Elements: " + rootElement.getChildNodes().getLength() + " Filesize: "
+ outputFile.length());
document = null;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(outputFile));
document = (Document) in.readObject();
in.close();
} catch (Throwable e) {
e.printStackTrace();
fail("Deserialisation failed : " + e.getMessage());
}
}
} finally {
try {
outputFile.delete();
} catch (Exception e) {
}
}
}
}
> Critical Object streaming error with large documents
> ----------------------------------------------------
>
> Key: XERCESJ-1037
> URL: http://issues.apache.org/jira/browse/XERCESJ-1037
> Project: Xerces2-J
> Type: Bug
> Components: DOM
> Versions: 2.6.2
> Environment: Windows XP, Sun, Linux, HP
> Reporter: Winfried Wasser
>
> When I try to stream an DOM Node (Document) with the standard Java Streaming API (by ObjectOutputStream) I get an StackOverflowError at Documents above a size of 600-800 (I can't determine this exactly) Elements. Sometimes I get this error at writing the Stream otherwise I get it at reading the Document from Stream.
> Its simple testable with an large Document parsed and Serialized by an ObjectOutputStream to an File - afterwards reading it back from this File --> and error is there.
--
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