Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Recursion

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: jcowan AT reutershealth.com
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Recursion
  • Date: Tue, 9 Mar 2004 22:40:08 -0500

At 4:32 PM -0500 3/9/04, jcowan AT reutershealth.com wrote:

Unfortunately, I think this is the important one, because it's not
replaceable. If you foresee a problem with serializing, you can use a
different serializer, but Element.copy and Element(anElement) are critical
parts of the API. And if you are running a server that is meant to handle
arbitrary incoming documents (and assuming you have some check for gross
size), then blowing up on nesting depth is really not acceptable.

How much nesting would typically be required to expose this? Personally, I've never noticed this problem when recursively processing a document with XOM or other APIs. How far can Java programs recurse before the stack blow up? Hundreds? Thousands? Millions? I have noticed when I accidentally write an infinite recursion it takes on the order of a minute before the program comes crashing down around me. That suggests it can go pretty deep.

A way to avoid the API wart would be to check if the element to be copied
is an actual Element or a subclass, and in the latter case, using
sourceElement.getClass().newInstance() to call the argless constructor.

But the subclass may not have a no-args constructor.
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page