Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On 11/04/2011 04:55 PM, Caolán McNamara wrote:
On Fri, 2011-11-04 at 16:23 +0100, Stephan Bergmann wrote:
Anyway, you have been warned.  ;)

Pfff, seems a sure route to madness to have to second guess every
possible java api over and above its documentation in case it uses some
ContextClassLoader under the hood. *shudder*, that'd be some audit
effort. Direct uses are one thing, but indirect hidden ones.

The context class loader is a dirty hack in the Java API, broken by design. Just goes to show how bad global variables are.

Anyway, is your suggested wrapper correct ? Looks a bit odd now that I
actually read it as opposed to boggle at it.

Just wrote it down as a quick sketch, so surely contains all sorts of errors.

      Thread.currentThread().setContextClassLoader(c); //like so I guess?

yes, sure

Anyway, given the code in question is likely called from the main thread, so would not exhibit any more of a problem than all the already existing instances of DocumentBuilderFactory.newInstance(), and presumably already works fine in master, I'm indifferent to whether any context class loader handling would be needed for a 3.4 cherry-pick after all... Consider it as approvingly reviewed by me either way.

(That said, I'll make a mental note to revisit the problem on master and maybe introduce some code abstraction to wrap around calls of DocumentBuilderFactory.newInstance() and similar constructs.)

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.