Possible parser reuse issue

Brent Putman putmanb at georgetown.edu
Fri Mar 13 20:06:21 EDT 2015



On 3/13/15 6:31 PM, John Landers wrote:
> We ran into an issue that the first call to BasicParserPool.parse
> fails but the second call with the same xml doesn't fail.
>
> I looked through the code and method on BasicParserPool: public void
> returnBuilder(DocumentBuilder builder)
> calls 
> unwrappedBuilder.reset();
>
> which resets the entityResolver and errorHandler back to the default
> constructor versions.
> So next time when using a parser from the pool it isn't using the
> BasicParserPool errorHandler 
> LoggingErrorHandler so parsing doesn't fail.
>


Yes, this is a bug.  I opened issues for both v2 [1] and v3 [2].

For v2 (which it appears you might be using given you had a
Configuration reference in there) this will be fixed on the main code
line (branches/REL_2), but I don't think we can guarantee when or even
if we'll see another v2 release.  You should strongly consider moving
to v3 sometime in the near future.

As a workaround for v2, I guess you can cast to DocumentBuilderProxy,
get the proxied DocumentBuilder and set the ErrorHandler yourself on
every call, or perhaps abstract via a subclass that overrides getBuilder().

Also: The BasicParserPool has some inefficiencies because it tries to
manage mutating properties of the pool over time, and versioning the
pool and its builders.  We don't actually use it any more in
Shibboleth.  Instead we use the StaticBasicParserPool, which you init
once and can't change, so it avoids all the versioning and dirty pool
config overhead.  (In v3/java-support, we only have the static one,
confusingly called BasicParserPool.)

Also, related:  In both looks like we don't even offer a way to set the
EntityResolver.  We have the (private) field there, but there is no
setter.  Also, the ErrorHandler is internally defaulted; we may want to
offer a public setter for these as well. [3]



[1] https://issues.shibboleth.net/jira/browse/JOST-241

[2] https://issues.shibboleth.net/jira/browse/JSPT-54

[3] https://issues.shibboleth.net/jira/browse/JSPT-55
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20150313/6ab12fd0/attachment.html 


More information about the dev mailing list