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 2026/04/15 11:56:57 UTC

(commons-configuration) 02/05: Internal refactoring

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 3dcb28a68ff238dc4fa39c737fd5a1c6014dcf55
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Apr 15 07:45:05 2026 -0400

    Internal refactoring
---
 .../org/apache/commons/configuration2/io/FileHandler.java     | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/configuration2/io/FileHandler.java b/src/main/java/org/apache/commons/configuration2/io/FileHandler.java
index 0feb3d163..11b31b297 100644
--- a/src/main/java/org/apache/commons/configuration2/io/FileHandler.java
+++ b/src/main/java/org/apache/commons/configuration2/io/FileHandler.java
@@ -549,12 +549,15 @@ public class FileHandler {
      * the case, a {@code FileLocator} instance is injected which returns only <strong>null</strong> values. This method is called if
      * no file location is available (for example if data is to be loaded from a stream). The encoding of the injected locator is
      * derived from this object.
+     *
+     * @return {@code this} instance.
      */
-    private void injectNullFileLocator() {
+    private FileHandler injectNullFileLocator() {
         if (getContent() instanceof FileLocatorAware) {
             final FileLocator locator = prepareNullLocatorBuilder().create();
             ((FileLocatorAware) getContent()).initFileLocator(locator);
         }
+        return this;
     }
 
     /**
@@ -642,8 +645,7 @@ public class FileHandler {
      * @throws ConfigurationException if an error occurs during the load operation
      */
     public void load(final Reader in) throws ConfigurationException {
-        checkContent().injectNullFileLocator();
-        loadFromReader(in);
+        checkContent().injectNullFileLocator().loadFromReader(in);
     }
 
     /**
@@ -1007,8 +1009,7 @@ public class FileHandler {
      * @throws ConfigurationException if an error occurs during the save operation
      */
     public void save(final Writer out) throws ConfigurationException {
-        checkContent().injectNullFileLocator();
-        saveToWriter(out);
+        checkContent().injectNullFileLocator().saveToWriter(out);
     }
 
     /**