[jdom-interest] Reusing parsers

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Apr 15 01:01:10 PDT 2003


Elliotte Rusty Harold wrote:
>> New method: SAXBuilder.setReuseParser(boolean)
>>
>> Default value is currently false, for safety.
> 
> This is unnecessary configuration. Too many options make an API hard to 
> understand. This is yet another method for clients to worry about. 
> SAXBuilder should either reuse parsers or not (probably it should reuse 
> them) but there's no reason to make this a configurable option.

The problem here is that I'm not sure all parsers support being reused in all 
cases. I suspects some parsers could not be reused after some parsing errors 
were encountered. This is the reason parser reuse is not the enabled by default.
Removing the method setReuseParser method would mean forcing parser reuse. I 
don't think we have enough feedback on this to do that yet.

But maybe setting the default to true would help us know whether reuse works 
100% of the time and decide if the method shall be removed in future releases.

> JavaDocs suggest this is for thread-safety, but I doubt SAXBuilder is 
> thread-safe whether we reuse parsers or not.  I suggest deleting this 
> method.

SAXBuilder is thread-safe as long as one does not register XMLFilters.

Laurent




More information about the jdom-interest mailing list