Skip to content

Commit f3c8c7b

Browse files
committed
Modernize I/O
1 parent c1d79b4 commit f3c8c7b

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/main/java/org/apache/maven/plugins/changes/schema/DefaultChangesSchemaValidator.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import org.apache.commons.io.input.XmlStreamReader;
3434
import org.codehaus.plexus.component.annotations.Component;
35-
import org.codehaus.plexus.util.IOUtil;
3635
import org.xml.sax.SAXException;
3736

3837
/**
@@ -88,26 +87,15 @@ public Schema getSchema(String schemaPath) throws SAXException, IOException {
8887
return schema;
8988
}
9089

91-
/**
92-
* @param uriSchema
93-
* @return Schema
94-
* @throws Exception
95-
*/
9690
private Schema compileJAXPSchema(String uriSchema) throws IOException, SAXException, NullPointerException {
97-
InputStream in = null;
98-
try {
99-
in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uriSchema);
91+
try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uriSchema)) {
10092
if (in == null) {
10193
throw new NullPointerException(" impossible to load schema with path " + uriSchema);
10294
}
10395

10496
// newInstance de SchemaFactory not ThreadSafe
10597
final Schema schema = SchemaFactory.newInstance(W3C_XML_SCHEMA).newSchema(new StreamSource(in));
106-
in.close();
107-
in = null;
10898
return schema;
109-
} finally {
110-
IOUtil.close(in);
11199
}
112100
}
113101

src/main/java/org/apache/maven/plugins/jira/JiraXML.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void parseXML(File xmlPath) throws MojoExecutionException {
9595
parse(inputSource);
9696
} catch (FileNotFoundException e) {
9797
throw new MojoExecutionException("Failed to open JIRA XML file " + xmlPath, e);
98-
} catch ( IOException e) {
98+
} catch (IOException e) {
9999
throw new MojoExecutionException("Failed to read JIRA XML file " + xmlPath, e);
100100
}
101101
}

0 commit comments

Comments
 (0)