diff --git a/sax/src/main/java/org/openjax/xml/sax/XmlCatalogResolver.java b/sax/src/main/java/org/openjax/xml/sax/XmlCatalogResolver.java index 392cd6c..a36504a 100644 --- a/sax/src/main/java/org/openjax/xml/sax/XmlCatalogResolver.java +++ b/sax/src/main/java/org/openjax/xml/sax/XmlCatalogResolver.java @@ -79,8 +79,14 @@ else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) { } } - if (entity == null) - return new CachedInputSource(publicId, systemId, baseURI, new URL(systemId).openConnection()); + if (entity == null) { + try { + return new CachedInputSource(publicId, systemId, baseURI, new URL(systemId).openConnection()); + } + catch (final IOException e) { + return null; + } + } final CachedInputSource inputSource = entity.getInputSource(); inputSource.getCharacterStream().close(); diff --git a/sax/src/test/java/org/openjax/xml/sax/FastSAXParserTest.java b/sax/src/test/java/org/openjax/xml/sax/FastSAXParserTest.java index f6ab732..50d0f6c 100644 --- a/sax/src/test/java/org/openjax/xml/sax/FastSAXParserTest.java +++ b/sax/src/test/java/org/openjax/xml/sax/FastSAXParserTest.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; -import java.util.List; import org.junit.Test; import org.libj.io.ReplayReader; @@ -136,7 +135,7 @@ public boolean attribute(final int prefix, final int localName, final int skip, } }; - private static void add(final List events, final Type type, final String ... fields) { + private static void add(final ArrayList events, final Type type, final String ... fields) { events.add(new Event(type, fields)); } @@ -155,7 +154,7 @@ private static void assertEvent(final Iterator iterator, final Reader in, assertEquals(event.fields[i], fields[i]); } - private static void test(final List events, final URL url) throws IOException, SAXParseException { + private static void test(final ArrayList events, final URL url) throws IOException, SAXParseException { final Iterator iterator = events.iterator(); try (final Reader in = new ReplayReader(new InputStreamReader(url.openStream()))) { FastSAXParser.parse(in, new FasterTestHandler(iterator, in)); @@ -164,7 +163,7 @@ private static void test(final List events, final URL url) throws IOExcep @Test public void testTestXsd() throws IOException, SAXParseException { - final List events = new ArrayList<>(); + final ArrayList events = new ArrayList<>(); add(events, Type.DOST); add(events, Type.CMNT, "\n Copyright (c) 2006 OpenJAX\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n You should have received a copy of The MIT License (MIT) along with this\n program. If not, see .\n"); add(events, Type.ELOP, "xs:", "schema"); @@ -289,7 +288,7 @@ public void testTestXsd() throws IOException, SAXParseException { @Test public void testNumeralsXml() throws IOException, SAXParseException { - final List events = new ArrayList<>(); + final ArrayList events = new ArrayList<>(); add(events, Type.DOST); add(events, Type.CMNT, "\n Copyright (c) 2008 OpenJAX\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n You should have received a copy of The MIT License (MIT) along with this\n program. If not, see .\n"); add(events, Type.ELOP, "xs:", "schema"); @@ -333,7 +332,7 @@ public void testNumeralsXml() throws IOException, SAXParseException { @Test public void testDoctypeXml() throws IOException, SAXParseException { - final List events = new ArrayList<>(); + final ArrayList events = new ArrayList<>(); add(events, Type.DOST); add(events, Type.CMNT, "\n Copyright (c) 2019 OpenJAX\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n You should have received a copy of The MIT License (MIT) along with this\n program. If not, see .\n"); add(events, Type.DOCT, "DOCTYPE catalog [\n \n \n \n]");