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 2024/12/16 11:39:14 UTC
(maven-scm-publish-plugin) branch master updated: Prefer try with resources (#49)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm-publish-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 3ae16a1 Prefer try with resources (#49)
3ae16a1 is described below
commit 3ae16a16d25ee1787b56058021c410f802e4cd13
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Mon Dec 16 11:39:10 2024 +0000
Prefer try with resources (#49)
---
.../scmpublish/ScmPublishPublishScmMojo.java | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
index 2413720..3c1f33a 100644
--- a/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
+++ b/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java
@@ -38,7 +38,6 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.NameFileFilter;
import org.apache.commons.io.filefilter.NotFileFilter;
import org.apache.maven.plugin.MojoExecutionException;
@@ -204,12 +203,10 @@ public class ScmPublishPublishScmMojo extends AbstractScmPublishMojo {
* @throws IOException
*/
private void copyAndNormalizeNewlines(File srcFile, File destFile) throws IOException {
- BufferedReader in = null;
- PrintWriter out = null;
- try {
- in = new BufferedReader(new InputStreamReader(Files.newInputStream(srcFile.toPath()), siteOutputEncoding));
- out = new PrintWriter(new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), siteOutputEncoding));
-
+ try (BufferedReader in = new BufferedReader(
+ new InputStreamReader(Files.newInputStream(srcFile.toPath()), siteOutputEncoding));
+ PrintWriter out = new PrintWriter(
+ new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), siteOutputEncoding))) {
for (String line = in.readLine(); line != null; line = in.readLine()) {
if (in.ready()) {
out.println(line);
@@ -217,14 +214,6 @@ public class ScmPublishPublishScmMojo extends AbstractScmPublishMojo {
out.print(line);
}
}
-
- out.close();
- out = null;
- in.close();
- in = null;
- } finally {
- IOUtils.closeQuietly(out);
- IOUtils.closeQuietly(in);
}
}
@@ -272,7 +261,7 @@ public class ScmPublishPublishScmMojo extends AbstractScmPublishMojo {
updateDirectory,
content,
(project == null) ? null : project.getModel().getModules());
- String displaySize = org.apache.commons.io.FileUtils.byteCountToDisplaySize(size);
+ String displaySize = FileUtils.byteCountToDisplaySize(size);
logInfo(
"Content consists of " + MessageUtils.buffer().strong("%d directories and %d files = %s"),
directories,