Repository: commons-release-plugin Updated Branches: refs/heads/master 63068ef85 -> 29c3d2d62
Use try-with-resources. Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/29c3d2d6 Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/29c3d2d6 Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/29c3d2d6 Branch: refs/heads/master Commit: 29c3d2d620c576fb8cad18798ed5ef32a43c8e27 Parents: 63068ef Author: Gary Gregory <[email protected]> Authored: Mon May 14 16:46:14 2018 -0600 Committer: Gary Gregory <[email protected]> Committed: Mon May 14 16:46:14 2018 -0600 ---------------------------------------------------------------------- .../plugin/mojos/CommonsDistributionDetachmentMojo.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/29c3d2d6/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java index 38cca8c..3587e64 100644 --- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java +++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java @@ -166,14 +166,14 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo { try { String md5 = DigestUtils.md5Hex(Files.readAllBytes(artifact.getFile().toPath())); getLog().info(artifact.getFile().getName() + " md5: " + md5); - PrintWriter md5Writer = new PrintWriter(getMd5FilePath(workingDirectory, artifact.getFile())); - md5Writer.println(md5); + try (PrintWriter md5Writer = new PrintWriter(getMd5FilePath(workingDirectory, artifact.getFile()))){ + md5Writer.println(md5); + } String sha1 = DigestUtils.sha1Hex(Files.readAllBytes(artifact.getFile().toPath())); getLog().info(artifact.getFile().getName() + " sha1: " + sha1); - PrintWriter sha1Writer = new PrintWriter(getSha1FilePath(workingDirectory, artifact.getFile())); - sha1Writer.println(sha1); - md5Writer.close(); - sha1Writer.close(); + try (PrintWriter sha1Writer = new PrintWriter(getSha1FilePath(workingDirectory, artifact.getFile()))) { + sha1Writer.println(sha1); + } } catch (IOException e) { throw new MojoExecutionException("Could not sign file: " + artifact.getFile().getName(), e); }
