Changeset 13715 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2018-05-08T12:37:26+02:00 (7 years ago)
Author:
Don-vip
Message:

see #16047 - implement workaround against problem seen with IcedTeaWeb 1.7.1 / Java 9 on Debian

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java

    r12881 r13715  
    2727import javax.xml.transform.stream.StreamSource;
    2828import javax.xml.validation.Schema;
    29 import javax.xml.validation.SchemaFactory;
    3029import javax.xml.validation.Validator;
    3130
    3231import org.openstreetmap.josm.io.CachedFile;
    3332import org.openstreetmap.josm.io.XmlStreamParsingException;
    34 import org.openstreetmap.josm.spi.preferences.Setting;
    3533import org.openstreetmap.josm.spi.preferences.ListListSetting;
    3634import org.openstreetmap.josm.spi.preferences.ListSetting;
    3735import org.openstreetmap.josm.spi.preferences.MapListSetting;
     36import org.openstreetmap.josm.spi.preferences.Setting;
    3837import org.openstreetmap.josm.spi.preferences.StringSetting;
    3938import org.openstreetmap.josm.tools.Logging;
     39import org.openstreetmap.josm.tools.Utils;
    4040import org.xml.sax.SAXException;
    4141
     
    9797    public static void validateXML(Reader in) throws IOException, SAXException {
    9898        try (CachedFile cf = new CachedFile("resource://data/preferences.xsd"); InputStream xsdStream = cf.getInputStream()) {
    99             Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(xsdStream));
     99            Schema schema = Utils.newXmlSchemaFactory().newSchema(new StreamSource(xsdStream));
    100100            Validator validator = schema.newValidator();
    101101            validator.validate(new StreamSource(in));
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r13649 r13715  
    4848import java.util.Locale;
    4949import java.util.Optional;
     50import java.util.ServiceConfigurationError;
    5051import java.util.concurrent.ExecutionException;
    5152import java.util.concurrent.Executor;
     
    7172import javax.xml.parsers.SAXParser;
    7273import javax.xml.parsers.SAXParserFactory;
     74import javax.xml.validation.SchemaFactory;
    7375
    7476import org.openstreetmap.josm.spi.preferences.Config;
     
    13271329        }
    13281330        return null;
     1331    }
     1332
     1333    /**
     1334     * Returns the W3C XML Schema factory implementation. Robust method dealing with ContextClassLoader problems.
     1335     * @return the W3C XML Schema factory implementation
     1336     * @since 13715
     1337     */
     1338    public static SchemaFactory newXmlSchemaFactory() {
     1339        try {
     1340            return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
     1341        } catch (ServiceConfigurationError e) {
     1342            Logging.debug(e);
     1343            // Can happen with icedtea-web. Use workaround from https://issues.apache.org/jira/browse/GERONIMO-6185
     1344            Thread currentThread = Thread.currentThread();
     1345            ClassLoader old = currentThread.getContextClassLoader();
     1346            currentThread.setContextClassLoader(null);
     1347            try {
     1348                return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
     1349            } finally {
     1350                currentThread.setContextClassLoader(old);
     1351            }
     1352        }
    13291353    }
    13301354
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r12624 r13715  
    1818import java.util.Stack;
    1919
    20 import javax.xml.XMLConstants;
    2120import javax.xml.parsers.ParserConfigurationException;
    2221import javax.xml.transform.stream.StreamSource;
     
    286285     */
    287286    public Iterable<Object> startWithValidation(final Reader in, String namespace, String schemaSource) throws SAXException {
    288         SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
     287        SchemaFactory factory = Utils.newXmlSchemaFactory();
    289288        try (CachedFile cf = new CachedFile(schemaSource); InputStream mis = cf.getInputStream()) {
    290289            Schema schema = factory.newSchema(new StreamSource(mis));
Note: See TracChangeset for help on using the changeset viewer.