You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/04/12 23:21:18 UTC
[maven-ejb-plugin] 01/01: use try with resources
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch io
in repository https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git
commit e79f2ac830066f726416974d1606cef25690ec64
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sun Apr 12 19:21:02 2020 -0400
use try with resources
---
src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
index 4d8d5ac..7dbeebe 100644
--- a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
@@ -25,7 +25,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
@@ -508,26 +507,17 @@ public class EjbMojo
/**
* Get the encoding from an XML-file.
*
- * @param xmlFile the XML-file
- * @return The encoding of the XML-file, or UTF-8 if it's not specified in the file
+ * @param xmlFile the XML file
+ * @return The encoding of the XML file, or UTF-8 if it's not specified in the file
* @throws IOException if an error occurred while reading the file
*/
private String getEncoding( File xmlFile )
throws IOException
{
- XmlStreamReader xmlReader = null;
- try
- {
- xmlReader = new XmlStreamReader( xmlFile );
+ try ( XmlStreamReader xmlReader = new XmlStreamReader( xmlFile ) ) {
final String encoding = xmlReader.getEncoding();
- xmlReader.close();
- xmlReader = null;
return encoding;
}
- finally
- {
- IOUtils.closeQuietly( xmlReader );
- }
}
public String getClassifier()