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

commit 7d15275d74b71be1fd366afa7a670b966b0d4fef
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sat Mar 15 15:38:05 2025 -0400

    Refactor AbstractPropertiesFactory.load(File|String) to use NIO
    
    - Refactor AbstractPropertiesFactory.load(File) to use NIO
    - Refactor AbstractPropertiesFactory.load(String) to use NIO
---
 src/changes/changes.xml                                          | 2 ++
 .../collections4/properties/AbstractPropertiesFactory.java       | 9 ++-------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index af193f82e..fea90ec01 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,8 @@
   <body>
   <release version="4.5.0-M4" date="YYYY-MM-DD" description="This is a feature 
and maintenance release. Java 8 or later is required.">
     <!-- FIX -->
+    <action type="fix" dev="ggregory" due-to="Gary Gregory">Refactor 
AbstractPropertiesFactory.load(File) to use NIO.</action>
+    <action type="fix" dev="ggregory" due-to="Gary Gregory">Refactor 
AbstractPropertiesFactory.load(String) to use NIO.</action>
     <!-- ADD -->
     <!-- UPDATE -->
     <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
commons-codec:commons-codec from 1.17.1 to 1.18.0 #591.</action>
diff --git 
a/src/main/java/org/apache/commons/collections4/properties/AbstractPropertiesFactory.java
 
b/src/main/java/org/apache/commons/collections4/properties/AbstractPropertiesFactory.java
index 1f937733f..97426e2aa 100644
--- 
a/src/main/java/org/apache/commons/collections4/properties/AbstractPropertiesFactory.java
+++ 
b/src/main/java/org/apache/commons/collections4/properties/AbstractPropertiesFactory.java
@@ -18,7 +18,6 @@
 package org.apache.commons.collections4.properties;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -100,9 +99,7 @@ public abstract class AbstractPropertiesFactory<T extends 
Properties> {
      *                                  the file.
      */
     public T load(final File file) throws FileNotFoundException, IOException {
-        try (FileInputStream inputStream = new FileInputStream(file)) {
-            return load(inputStream, 
PropertyFormat.toPropertyFormat(file.getName()));
-        }
+        return load(file.toPath());
     }
 
     /**
@@ -182,9 +179,7 @@ public abstract class AbstractPropertiesFactory<T extends 
Properties> {
      * @throws IllegalArgumentException Thrown if the input contains a 
malformed Unicode escape sequence.
      */
     public T load(final String name) throws IOException {
-        try (FileInputStream inputStream = new FileInputStream(name)) {
-            return load(inputStream, PropertyFormat.toPropertyFormat(name));
-        }
+        return load(Paths.get(name));
     }
 
     /**

Reply via email to