diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/validation/XmlSchemaContentValidator.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/validation/XmlSchemaContentValidator.java index 9966a45f3..e94b00a72 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/validation/XmlSchemaContentValidator.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/validation/XmlSchemaContentValidator.java @@ -37,18 +37,28 @@ public class XmlSchemaContentValidator extends AbstractContentValidator { private final Schema schema; - @SuppressWarnings("null") + @SuppressWarnings({ "resource", "PMD.UseTryWithResources" }) @NonNull private static Schema toSchema(@NonNull List schemaSources) throws IOException { SchemaFactory schemafactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // schemafactory.setResourceResolver(new ClasspathResourceResolver()); // TODO verify source input streams are closed try { - return schemaSources.isEmpty() + return ObjectUtils.notNull(schemaSources.isEmpty() ? schemafactory.newSchema() - : schemafactory.newSchema(schemaSources.toArray(new Source[0])); + : schemafactory.newSchema(schemaSources.toArray(new Source[0]))); } catch (SAXException ex) { throw new IOException(ex); + } finally { + // Close all source input streams + for (Source source : schemaSources) { + if (source instanceof StreamSource) { + StreamSource streamSource = (StreamSource) source; + if (streamSource.getInputStream() != null) { + streamSource.getInputStream().close(); + } + } + } } } diff --git a/pom.xml b/pom.xml index 0e495dbc1..ac9b6b90b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ dev.metaschema oss-parent - 5 + 6-SNAPSHOT dev.metaschema.java @@ -57,7 +57,6 @@ 2.0.6.1 2.13.1 20240303 - 5.11.3 2.24.1 2.9.3 5.14.2 @@ -65,9 +64,7 @@ ${project.parent.version} 4.0.2 1.2.0 - 7.7.0 12.5 - 4.8.6 4.2.2 3.1.2.RELEASE 7.1.0 @@ -82,13 +79,7 @@ 1.22 2.1.0 9.0.1 - 3.11.1 - 2.12.1 - 3.8.1 - 3.2.0 - 3.26.0 - 4.8.6.5 - 3.5.2 + 3.0.0 -Xmx1024m @@ -437,11 +428,6 @@ compiler 2.26ea0 - - com.github.spotbugs - spotbugs-annotations - ${dependency.spotbugs-annotations.version} - org.eclipse.jdt org.eclipse.jdt.annotation @@ -452,13 +438,6 @@ caffeine ${dependency.caffeine.version} - - org.junit - junit-bom - ${dependency.junit5.version} - pom - import - org.jmock jmock-junit5 @@ -500,11 +479,6 @@ ${dependency.assertj.version} test - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.15.1 - biz.aQute.bnd @@ -549,7 +523,6 @@ org.apache.maven.plugins maven-toolchains-plugin - ${plugin.maven-toolchains.version} @@ -642,7 +615,6 @@ org.apache.maven.plugins maven-jxr-plugin - 3.6.0 **/module-info.java @@ -652,7 +624,6 @@ org.apache.maven.plugins maven-javadoc-plugin - ${plugin.maven-javadoc.version} *.xmlbeans:*.xmlbeans.*:*.antlr false @@ -679,18 +650,12 @@ com.github.spotbugs spotbugs-maven-plugin - ${plugin.spotbugs.version} spotbugs-exclude.xml true spotbugs.sarif - - org.apache.maven.plugins - maven-invoker-plugin - ${plugin.maven-invoker.version} - io.github.git-commit-id git-commit-id-maven-plugin @@ -714,7 +679,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${plugin.maven-surefire.version} 1.5C true @@ -729,19 +693,6 @@ org.apache.maven.plugins maven-pmd-plugin - ${plugin.pmd.version} - - - net.sourceforge.pmd - pmd-core - ${dependency.pmd.version} - - - net.sourceforge.pmd - pmd-java - ${dependency.pmd.version} - - pmd-verify