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 2022/05/22 12:45:40 UTC

[commons-daemon] branch master updated (701e935 -> 42253ad)

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-daemon.git


    from 701e935  Increment version from 1.3.1 to 1.3.2 for next development cycle
     new 6ca8e27  Comment empty block
     new cd97e73  Better local var name
     new 42253ad  Use try-with-resources

The 3 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:
 .../daemon/support/DaemonConfiguration.java        | 29 ++++++++--------------
 1 file changed, 10 insertions(+), 19 deletions(-)


[commons-daemon] 02/03: Better local var name

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-daemon.git

commit cd97e733c662d8c8a221d895edb4536baa5f538c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 08:22:26 2022 -0400

    Better local var name
---
 .../org/apache/commons/daemon/support/DaemonConfiguration.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
index bb7bbc8..b712205 100644
--- a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
+++ b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
@@ -85,22 +85,22 @@ public final class DaemonConfiguration
     public boolean load(String fileName)
     {
         boolean ok = false;
-        FileInputStream file = null;
+        FileInputStream inputStream = null;
         try {
             if (fileName == null) {
                 fileName = DEFAULT_CONFIG;
             }
-            file = new FileInputStream(fileName);
+            inputStream = new FileInputStream(fileName);
             configurationProperties.clear();
-            configurationProperties.load(file);
+            configurationProperties.load(inputStream);
             ok = true;
         }
         catch (final IOException ex) {
             // Error reading properties file
         } finally {
             try {
-                if (file != null) {
-                    file.close();
+                if (inputStream != null) {
+                    inputStream.close();
                 }
             } catch (final IOException ex) {
                 // ignore


[commons-daemon] 03/03: Use try-with-resources

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-daemon.git

commit 42253ad2445e1a2066872718c0e79232cec7e40d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 08:45:36 2022 -0400

    Use try-with-resources
---
 .../daemon/support/DaemonConfiguration.java        | 28 +++++++---------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
index b712205..bd46443 100644
--- a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
+++ b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.commons.daemon.support;
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Properties;
 import java.text.ParseException;
@@ -84,29 +85,18 @@ public final class DaemonConfiguration
      */
     public boolean load(String fileName)
     {
-        boolean ok = false;
-        FileInputStream inputStream = null;
-        try {
-            if (fileName == null) {
-                fileName = DEFAULT_CONFIG;
-            }
-            inputStream = new FileInputStream(fileName);
+        if (fileName == null) {
+            fileName = DEFAULT_CONFIG;
+        }
+        
+        try (InputStream inputStream = new FileInputStream(fileName)) {
             configurationProperties.clear();
             configurationProperties.load(inputStream);
-            ok = true;
-        }
-        catch (final IOException ex) {
+            return true;
+        } catch (final IOException ex) {
             // Error reading properties file
-        } finally {
-            try {
-                if (inputStream != null) {
-                    inputStream.close();
-                }
-            } catch (final IOException ex) {
-                // ignore
-            }
+            return false;
         }
-        return ok;
     }
 
     private String expandProperty(final String propValue)


[commons-daemon] 01/03: Comment empty block

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-daemon.git

commit 6ca8e27b3c835254d4cd901824e1ade0be4f1d57
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 08:22:09 2022 -0400

    Comment empty block
---
 src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
index 417d99e..bb7bbc8 100644
--- a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
+++ b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
@@ -103,6 +103,7 @@ public final class DaemonConfiguration
                     file.close();
                 }
             } catch (final IOException ex) {
+                // ignore
             }
         }
         return ok;