When encrypt xml documents large then 5MB using org.apache.xml.security.encryption.XMLCipher Exception in thread "main" java.lang.StackOverflowError > at org.apache.xerces.dom.ParentNode.internalRemoveChild(Unknown Source) > at org.apache.xerces.dom.ParentNode.removeChild(Unknown Source) > at org.apache.xml.security.encryption.XMLCipher.removeContent(Unknown So > urce) > at org.apache.xml.security.encryption.XMLCipher.removeContent(Unknown So then bag is in implementation : (recursive invocation) private void removeContent(Node node) { NodeList list = node.getChildNodes(); if (list.getLength() > 0) { Node n = list.item(0); if (null != n) { n.getParentNode().removeChild(n); } removeContent(node); } } I'm sugesting change it, for example: private void removeContent(Node node) { NodeList list = node.getChildNodes(); while(list.getLength() > 0) { Node n = list.item(0); if (null != n) { n.getParentNode().removeChild(n); } } }
Fixed.
Closing old bugs. Fixed in 1.4.1
removeContent doesn't work reliably in 1.4.1 it does not remove all children. the loop finishes to early I've found this buggy code private void removeContent(Node node) { NodeList list = node.getChildNodes(); for (int i=0; i<list.getLength(); i++) { Node n = list.item(i); if (n != null) { n.getParentNode().removeChild(n); } } } example: if you have two childs, the first is removed, getLength is changed, the second child isn't removed Try the suggestion from the first poster
(In reply to comment #3) > removeContent doesn't work reliably in 1.4.1 > it does not remove all children. This is a dup of bug #42886, which will be fixed in 1.4.2. *** This bug has been marked as a duplicate of 42886 ***