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 2025/04/07 13:29:13 UTC

(commons-configuration) branch master updated (24a2c539 -> 4938df06)

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


    from 24a2c539 Bump org.apache.commons:commons-vfs2 from 2.9.0 to 2.10.0
     new e53dd2b8 Sort members
     new 9c2aea75 No need to nest, simplify flow
     new 4938df06 No need to nest, simplify flow

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:
 .../configuration2/AbstractConfiguration.java      |  8 ++---
 .../configuration2/convert/PropertyConverter.java  | 42 ++++++++++++++--------
 .../spring/ConfigurationPropertySource.java        | 19 +++++-----
 .../commons/configuration2/io/TestFileHandler.java |  8 ++---
 4 files changed, 45 insertions(+), 32 deletions(-)


(commons-configuration) 01/03: 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-configuration.git

commit e53dd2b89f5a6aee4cc38a55fa9b9064754d84c0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 7 09:22:40 2025 -0400

    Sort members
---
 .../org/apache/commons/configuration2/AbstractConfiguration.java  | 8 ++++----
 .../org/apache/commons/configuration2/io/TestFileHandler.java     | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java b/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
index ffc8e40d..eb198664 100644
--- a/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
+++ b/src/main/java/org/apache/commons/configuration2/AbstractConfiguration.java
@@ -1521,19 +1521,19 @@ public abstract class AbstractConfiguration extends BaseEventSource implements C
         return new SubsetConfiguration(this, prefix, DELIMITER);
     }
 
-    void syncRead(final Runnable runnable, final boolean optimize) {
+    <T, E extends Throwable> T syncRead(final FailableSupplier<T, E> supplier, final boolean optimize) throws E {
         beginRead(optimize);
         try {
-            runnable.run();
+            return supplier.get();
         } finally {
             endRead();
         }
     }
 
-    <T, E extends Throwable> T syncRead(final FailableSupplier<T, E> supplier, final boolean optimize) throws E {
+    void syncRead(final Runnable runnable, final boolean optimize) {
         beginRead(optimize);
         try {
-            return supplier.get();
+            runnable.run();
         } finally {
             endRead();
         }
diff --git a/src/test/java/org/apache/commons/configuration2/io/TestFileHandler.java b/src/test/java/org/apache/commons/configuration2/io/TestFileHandler.java
index 10ec8bb1..5fca03ea 100644
--- a/src/test/java/org/apache/commons/configuration2/io/TestFileHandler.java
+++ b/src/test/java/org/apache/commons/configuration2/io/TestFileHandler.java
@@ -302,6 +302,10 @@ public class TestFileHandler {
         });
     }
 
+    private Path createTestPath() {
+        return createTestFile().toPath();
+    }
+
     private URI createTestURI() {
         return createTestFile().toURI();
     }
@@ -682,10 +686,6 @@ public class TestFileHandler {
         assertEquals(CONTENT, content.getContent());
     }
 
-    private Path createTestPath() {
-        return createTestFile().toPath();
-    }
-
     /**
      * Tests whether data from a URL can be loaded.
      */


(commons-configuration) 02/03: No need to nest, simplify flow

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

commit 9c2aea75eaca3fdcf819027a54fa1e8aaf3393a9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 7 09:28:59 2025 -0400

    No need to nest, simplify flow
---
 .../spring/ConfigurationPropertySource.java           | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
index e5ee819a..440935bd 100644
--- a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
+++ b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
@@ -50,18 +50,17 @@ public class ConfigurationPropertySource extends EnumerablePropertySource<Config
 
     @Override
     public Object getProperty(final String name) {
-        if (source.getProperty(name) != null) {
-            final String[] propValue = source.getStringArray(name);
-            if (propValue == null || propValue.length == 0) {
-                return "";
-            } else if (propValue.length == 1) {
-                return propValue[0];
-            } else {
-                return propValue;
-            }
-        } else {
+        if (source.getProperty(name) == null) {
             return null;
         }
+        final String[] propValue = source.getStringArray(name);
+        if (propValue == null || propValue.length == 0) {
+            return "";
+        }
+        if (propValue.length == 1) {
+            return propValue[0];
+        }
+        return propValue;
     }
 
     @Override


(commons-configuration) 03/03: No need to nest, simplify flow

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

commit 4938df066196d5bc5ef2e4324affc8ae5b065a6f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Apr 7 09:29:04 2025 -0400

    No need to nest, simplify flow
---
 .../configuration2/convert/PropertyConverter.java  | 42 ++++++++++++++--------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java b/src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java
index aa99230f..fefdcc6e 100644
--- a/src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java
+++ b/src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java
@@ -139,35 +139,49 @@ public final class PropertyConverter {
                 return toBigDecimal(value);
             }
             return toNumber(value, cls);
-        } else if (Date.class.equals(cls)) {
+        }
+        if (Date.class.equals(cls)) {
             return toDate(value, convHandler.getDateFormat());
-        } else if (Calendar.class.equals(cls)) {
+        }
+        if (Calendar.class.equals(cls)) {
             return toCalendar(value, convHandler.getDateFormat());
-        } else if (File.class.equals(cls)) {
+        }
+        if (File.class.equals(cls)) {
             return toFile(value);
-        } else if (Path.class.equals(cls)) {
+        }
+        if (Path.class.equals(cls)) {
             return toPath(value);
-        } else if (URI.class.equals(cls)) {
+        }
+        if (URI.class.equals(cls)) {
             return toURI(value);
-        } else if (URL.class.equals(cls)) {
+        }
+        if (URL.class.equals(cls)) {
             return toURL(value);
-        } else if (Pattern.class.equals(cls)) {
+        }
+        if (Pattern.class.equals(cls)) {
             return toPattern(value);
-        } else if (Locale.class.equals(cls)) {
+        }
+        if (Locale.class.equals(cls)) {
             return toLocale(value);
-        } else if (cls.isEnum()) {
+        }
+        if (cls.isEnum()) {
             return convertToEnum(cls, value);
-        } else if (Color.class.equals(cls)) {
+        }
+        if (Color.class.equals(cls)) {
             return toColor(value);
-        } else if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME_JAVAX)) {
+        }
+        if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME_JAVAX)) {
             // javamail-1.* With javax.mail.* namespace.
             return toInternetAddress(value, INTERNET_ADDRESS_CLASSNAME_JAVAX);
-        } else if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME_JAKARTA)) {
+        }
+        if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME_JAKARTA)) {
             // javamail-2.0+, with jakarta.mail.* namespace.
             return toInternetAddress(value, INTERNET_ADDRESS_CLASSNAME_JAKARTA);
-        } else if (InetAddress.class.isAssignableFrom(cls)) {
+        }
+        if (InetAddress.class.isAssignableFrom(cls)) {
             return toInetAddress(value);
-        } else if (Duration.class.equals(cls)) {
+        }
+        if (Duration.class.equals(cls)) {
             return toDuration(value);
         }