Skip to content

Commit 7d15275

Browse files
committed
Refactor AbstractPropertiesFactory.load(File|String) to use NIO
- Refactor AbstractPropertiesFactory.load(File) to use NIO - Refactor AbstractPropertiesFactory.load(String) to use NIO
1 parent 3ccf6db commit 7d15275

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/changes/changes.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<body>
2525
<release version="4.5.0-M4" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
2626
<!-- FIX -->
27+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Refactor AbstractPropertiesFactory.load(File) to use NIO.</action>
28+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Refactor AbstractPropertiesFactory.load(String) to use NIO.</action>
2729
<!-- ADD -->
2830
<!-- UPDATE -->
2931
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-codec:commons-codec from 1.17.1 to 1.18.0 #591.</action>

src/main/java/org/apache/commons/collections4/properties/AbstractPropertiesFactory.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.commons.collections4.properties;
1919

2020
import java.io.File;
21-
import java.io.FileInputStream;
2221
import java.io.FileNotFoundException;
2322
import java.io.IOException;
2423
import java.io.InputStream;
@@ -100,9 +99,7 @@ public T load(final ClassLoader classLoader, final String name) throws IOExcepti
10099
* the file.
101100
*/
102101
public T load(final File file) throws FileNotFoundException, IOException {
103-
try (FileInputStream inputStream = new FileInputStream(file)) {
104-
return load(inputStream, PropertyFormat.toPropertyFormat(file.getName()));
105-
}
102+
return load(file.toPath());
106103
}
107104

108105
/**
@@ -182,9 +179,7 @@ public T load(final Reader reader) throws IOException {
182179
* @throws IllegalArgumentException Thrown if the input contains a malformed Unicode escape sequence.
183180
*/
184181
public T load(final String name) throws IOException {
185-
try (FileInputStream inputStream = new FileInputStream(name)) {
186-
return load(inputStream, PropertyFormat.toPropertyFormat(name));
187-
}
182+
return load(Paths.get(name));
188183
}
189184

190185
/**

0 commit comments

Comments
 (0)