You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/27 14:45:51 UTC

[commons-release-plugin] branch master updated (cd3769c -> 1c3468d)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git.


    from cd3769c  Don't catch NPE (SpotBugs).
     new dfc8604  Don't catch NPE (SpotBugs).
     new 1c3468d  Sort members.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/release/plugin/SharedFunctions.java    | 101 +++++++++++----------
 1 file changed, 51 insertions(+), 50 deletions(-)

[commons-release-plugin] 02/02: Sort members.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git

commit 1c3468d72202d957e4a30203ba43d9456ffc54cf
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 27 09:45:48 2021 -0500

    Sort members.
---
 .../commons/release/plugin/SharedFunctions.java    | 102 ++++++++++-----------
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
index 6861cda..91c1d9e 100755
--- a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
+++ b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
@@ -46,10 +46,51 @@ public final class SharedFunctions {
     public static final int BUFFER_BYTE_SIZE = 1024;
 
     /**
-     * Making the constructor private because the class only contains static methods.
+     * Copies a {@link File} from the <code>fromFile</code> to the <code>toFile</code> and logs the failure
+     * using the Maven {@link Log}.
+     *
+     * @param log the {@link Log}, the maven logger.
+     * @param fromFile the {@link File} from which to copy.
+     * @param toFile the {@link File} to which to copy into.
+     * @throws MojoExecutionException if an {@link IOException} or {@link NullPointerException} is caught.
      */
-    private SharedFunctions() {
-        // Utility Class
+    public static void copyFile(final Log log, final File fromFile, final File toFile) throws MojoExecutionException {
+        final String format = "Unable to copy file %s tp %s: %s";
+        requireNonNull(fromFile, () -> String.format(format, fromFile, toFile));
+        requireNonNull(toFile, () -> String.format(format, fromFile, toFile));
+        try {
+            FileUtils.copyFile(fromFile, toFile);
+        } catch (final IOException e) {
+            final String message = String.format(format, fromFile, toFile, e.getMessage());
+            log.error(message);
+            throw new MojoExecutionException(message, e);
+        }
+    }
+
+    /**
+     * Cleans and then initializes an empty directory that is given by the <code>workingDirectory</code>
+     * parameter.
+     *
+     * @param log is the Maven log for output logging, particularly in regards to error management.
+     * @param workingDirectory is a {@link File} that represents the directory to first attempt to delete then create.
+     * @throws MojoExecutionException when an {@link IOException} or {@link NullPointerException} is caught for the
+     *      purpose of bubbling the exception up to Maven properly.
+     */
+    public static void initDirectory(final Log log, final File workingDirectory) throws MojoExecutionException {
+        final String format = "Unable to remove directory %s: %s";
+        requireNonNull(workingDirectory, () -> String.format(format, workingDirectory));
+        if (workingDirectory.exists()) {
+            try {
+                FileUtils.deleteDirectory(workingDirectory);
+            } catch (final IOException e) {
+                final String message = String.format(format, workingDirectory, e.getMessage());
+                log.error(message);
+                throw new MojoExecutionException(message, e);
+            }
+        }
+        if (!workingDirectory.exists()) {
+            workingDirectory.mkdirs();
+        }
     }
 
     /**
@@ -125,54 +166,6 @@ public final class SharedFunctions {
     }
 
     /**
-     * Cleans and then initializes an empty directory that is given by the <code>workingDirectory</code>
-     * parameter.
-     *
-     * @param log is the Maven log for output logging, particularly in regards to error management.
-     * @param workingDirectory is a {@link File} that represents the directory to first attempt to delete then create.
-     * @throws MojoExecutionException when an {@link IOException} or {@link NullPointerException} is caught for the
-     *      purpose of bubbling the exception up to Maven properly.
-     */
-    public static void initDirectory(final Log log, final File workingDirectory) throws MojoExecutionException {
-        final String format = "Unable to remove directory %s: %s";
-        requireNonNull(workingDirectory, () -> String.format(format, workingDirectory));
-        if (workingDirectory.exists()) {
-            try {
-                FileUtils.deleteDirectory(workingDirectory);
-            } catch (final IOException e) {
-                final String message = String.format(format, workingDirectory, e.getMessage());
-                log.error(message);
-                throw new MojoExecutionException(message, e);
-            }
-        }
-        if (!workingDirectory.exists()) {
-            workingDirectory.mkdirs();
-        }
-    }
-
-    /**
-     * Copies a {@link File} from the <code>fromFile</code> to the <code>toFile</code> and logs the failure
-     * using the Maven {@link Log}.
-     *
-     * @param log the {@link Log}, the maven logger.
-     * @param fromFile the {@link File} from which to copy.
-     * @param toFile the {@link File} to which to copy into.
-     * @throws MojoExecutionException if an {@link IOException} or {@link NullPointerException} is caught.
-     */
-    public static void copyFile(final Log log, final File fromFile, final File toFile) throws MojoExecutionException {
-        final String format = "Unable to copy file %s tp %s: %s";
-        requireNonNull(fromFile, () -> String.format(format, fromFile, toFile));
-        requireNonNull(toFile, () -> String.format(format, fromFile, toFile));
-        try {
-            FileUtils.copyFile(fromFile, toFile);
-        } catch (final IOException e) {
-            final String message = String.format(format, fromFile, toFile, e.getMessage());
-            log.error(message);
-            throw new MojoExecutionException(message, e);
-        }
-    }
-
-    /**
      * Set authentication information on the specified {@link ScmProviderRepository}.
      * @param providerRepository target.
      * @param distServer temp.
@@ -194,4 +187,11 @@ public final class SharedFunctions {
         providerRepository.setUser(server.map(Server::getUsername).orElse(username));
         providerRepository.setPassword(server.map(Server::getPassword).orElse(password));
     }
+
+    /**
+     * Making the constructor private because the class only contains static methods.
+     */
+    private SharedFunctions() {
+        // Utility Class
+    }
 }

[commons-release-plugin] 01/02: Don't catch NPE (SpotBugs).

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git

commit dfc860468bf028a1ac762473e03872b1b7dbb1b6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 27 09:44:48 2021 -0500

    Don't catch NPE (SpotBugs).
    
    Reimplement catch and rethrow NPE in the style of
    Objects#requireNonNull() and don't log NPE, just percolate as Mojo
    exception.
---
 .../java/org/apache/commons/release/plugin/SharedFunctions.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
index 770a786..6861cda 100755
--- a/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
+++ b/src/main/java/org/apache/commons/release/plugin/SharedFunctions.java
@@ -134,12 +134,13 @@ public final class SharedFunctions {
      *      purpose of bubbling the exception up to Maven properly.
      */
     public static void initDirectory(final Log log, final File workingDirectory) throws MojoExecutionException {
+        final String format = "Unable to remove directory %s: %s";
+        requireNonNull(workingDirectory, () -> String.format(format, workingDirectory));
         if (workingDirectory.exists()) {
             try {
                 FileUtils.deleteDirectory(workingDirectory);
-            } catch (final IOException | NullPointerException e) {
-                final String message = String.format("Unable to remove directory %s: %s", workingDirectory,
-                        e.getMessage());
+            } catch (final IOException e) {
+                final String message = String.format(format, workingDirectory, e.getMessage());
                 log.error(message);
                 throw new MojoExecutionException(message, e);
             }