Skip to content

Commit c1d79b4

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

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.File;
2525
import java.io.FileInputStream;
2626
import java.io.FileNotFoundException;
27+
import java.io.IOException;
2728
import java.io.InputStream;
2829
import java.text.ParseException;
2930
import java.text.SimpleDateFormat;
@@ -35,7 +36,6 @@
3536
import org.apache.maven.plugin.MojoExecutionException;
3637
import org.apache.maven.plugin.logging.Log;
3738
import org.apache.maven.plugins.issues.Issue;
38-
import org.codehaus.plexus.util.IOUtil;
3939
import org.xml.sax.Attributes;
4040
import org.xml.sax.InputSource;
4141
import org.xml.sax.helpers.DefaultHandler;
@@ -64,8 +64,8 @@ public class JiraXML extends DefaultHandler {
6464
private SimpleDateFormat sdf;
6565

6666
/**
67-
* @param log not null.
68-
* @param datePattern may be null.
67+
* @param log not null
68+
* @param datePattern may be null
6969
* @since 2.4
7070
*/
7171
public JiraXML(Log log, String datePattern) {
@@ -83,22 +83,20 @@ public JiraXML(Log log, String datePattern) {
8383
}
8484

8585
/**
86-
* Parse the given xml file. The list of issues can then be retrieved with {@link #getIssueList()}.
86+
* Parse the given XML file. The list of issues can then be retrieved with {@link #getIssueList()}.
8787
*
88-
* @param xmlPath the file to pares.
89-
* @throws MojoExecutionException in case of errors.
88+
* @param xmlPath the file to parse
89+
* @throws MojoExecutionException in case of errors
9090
* @since 2.4
9191
*/
9292
public void parseXML(File xmlPath) throws MojoExecutionException {
93-
InputStream xmlStream = null;
94-
try {
95-
xmlStream = new FileInputStream(xmlPath);
93+
try (InputStream xmlStream = new FileInputStream(xmlPath)) {
9694
InputSource inputSource = new InputSource(xmlStream);
9795
parse(inputSource);
9896
} catch (FileNotFoundException e) {
9997
throw new MojoExecutionException("Failed to open JIRA XML file " + xmlPath, e);
100-
} finally {
101-
IOUtil.close(xmlStream);
98+
} catch ( IOException e) {
99+
throw new MojoExecutionException("Failed to read JIRA XML file " + xmlPath, e);
102100
}
103101
}
104102

0 commit comments

Comments
 (0)