From 3d0bea9a3b160eb9f826e521e7cc00dc0a2b7649 Mon Sep 17 00:00:00 2001 From: Daniel Roberts Date: Tue, 7 Jan 2025 20:18:48 -0500 Subject: [PATCH] Use a FileHandler when loading properties (#5233) Fixes error when using include or includeOptional property directives in accumulo.properties --- .../java/org/apache/accumulo/core/conf/SiteConfiguration.java | 4 +++- .../accumulo/start/classloader/AccumuloClassLoader.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java index 196486f205c..2a54943217b 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java @@ -39,6 +39,7 @@ import org.apache.commons.configuration2.MapConfiguration; import org.apache.commons.configuration2.PropertiesConfiguration; import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.configuration2.io.FileHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -222,8 +223,9 @@ private SiteConfiguration(Map config) { private static AbstractConfiguration getPropsFileConfig(URL accumuloPropsLocation) { var config = new PropertiesConfiguration(); if (accumuloPropsLocation != null) { + var fileHandler = new FileHandler(config); try (var reader = new InputStreamReader(accumuloPropsLocation.openStream(), UTF_8)) { - config.read(reader); + fileHandler.load(reader); } catch (ConfigurationException | IOException e) { throw new IllegalArgumentException(e); } diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java index 3a816dcf9a8..72c76eaa106 100644 --- a/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java +++ b/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.io.FileHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,8 +91,9 @@ public static String getAccumuloProperty(String propertyName, String defaultValu } try { var config = new PropertiesConfiguration(); + var fileHandler = new FileHandler(config); try (var reader = new InputStreamReader(accumuloConfigUrl.openStream(), UTF_8)) { - config.read(reader); + fileHandler.load(reader); } String value = config.getString(propertyName); if (value != null) {