Skip to content

Commit

Permalink
Modernize I/O
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Nov 22, 2024
1 parent c1d79b4 commit f3c8c7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import org.apache.commons.io.input.XmlStreamReader;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.xml.sax.SAXException;

/**
Expand Down Expand Up @@ -88,26 +87,15 @@ public Schema getSchema(String schemaPath) throws SAXException, IOException {
return schema;
}

/**
* @param uriSchema
* @return Schema
* @throws Exception
*/
private Schema compileJAXPSchema(String uriSchema) throws IOException, SAXException, NullPointerException {
InputStream in = null;
try {
in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uriSchema);
try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uriSchema)) {
if (in == null) {
throw new NullPointerException(" impossible to load schema with path " + uriSchema);
}

// newInstance de SchemaFactory not ThreadSafe
final Schema schema = SchemaFactory.newInstance(W3C_XML_SCHEMA).newSchema(new StreamSource(in));
in.close();
in = null;
return schema;
} finally {
IOUtil.close(in);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/maven/plugins/jira/JiraXML.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void parseXML(File xmlPath) throws MojoExecutionException {
parse(inputSource);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Failed to open JIRA XML file " + xmlPath, e);
} catch ( IOException e) {
} catch (IOException e) {
throw new MojoExecutionException("Failed to read JIRA XML file " + xmlPath, e);
}
}
Expand Down

0 comments on commit f3c8c7b

Please sign in to comment.