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


On 11/04/2011 12:41 PM, Caolán McNamara wrote:
i.e. com.sun.org.apache.xerces.internal.parsers.DOMParser is a
sun/oracle-only java api. Commit
http://cgit.freedesktop.org/libreoffice/core/commit/?id=04c5a36ab8d514cfbe8e40f4493787b2ab392ab5
(attached) I believe does the right thing, definitely builds anyway.

Looking at the patch, javax.xml.parsers.DocumentBuilderFactory.newInstance() smells like it internally uses the context class loader, even if that is not documented at <http://download.oracle.com/javase/7/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance()> (and at least in some Sun JRE 6 it indeed does so), so this could fail if the context class loader is null---as can happen in LibO, see <https://issues.apache.org/ooo/show_bug.cgi?id=102164#c6>.

That is, the call to DocumentBuilderFactory.newInstance() within OfficeDocumentReportTarget would need to be wrapped in something like

DocumentBuilderFactory dbFactory;
ClassLoader old = Thread.currentThread().getContextClassLoader();
ClassLoader c = OfficeDocumentReportTarget.class.getClassLoader();
if (c != null) {
    // otherwise, hope context class loader already contains a non-null value
    OfficeDocumentReportTarget.class.getClassLoader(c);
}
try {
    dbFactory = DocumentBuilderFactory.newInstance();
} finally {
    if (c != null) {
        Thread.currentThread().setContextClassLoader(old);
    }
}

Stepha

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.