This is an automated email from the ASF dual-hosted git repository.
stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new ce51048 HADOOP-16925. MetricsConfig incorrectly loads the
configuration whose value is String list in the properties file (#1896)
ce51048 is described below
commit ce51048e8c8432a1564add1aedb92fbd150ab200
Author: Joey <[email protected]>
AuthorDate: Mon Aug 24 21:01:48 2020 +0800
HADOOP-16925. MetricsConfig incorrectly loads the configuration whose value
is String list in the properties file (#1896)
Contributed by Jiayi Liu
---
.../org/apache/hadoop/metrics2/impl/MetricsConfig.java | 2 ++
.../apache/hadoop/metrics2/impl/TestMetricsConfig.java | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java
index 976f16b..a1f4d23 100644
---
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java
+++
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java
@@ -37,6 +37,7 @@ import com.google.common.collect.Maps;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.SubsetConfiguration;
+import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.configuration2.io.FileHandler;
import org.apache.hadoop.metrics2.MetricsFilter;
@@ -111,6 +112,7 @@ class MetricsConfig extends SubsetConfiguration {
for (String fname : fileNames) {
try {
PropertiesConfiguration pcf = new PropertiesConfiguration();
+ pcf.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
FileHandler fh = new FileHandler(pcf);
fh.setFileName(fname);
fh.load();
diff --git
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsConfig.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsConfig.java
index b53be4d..2ca1c8a 100644
---
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsConfig.java
+++
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestMetricsConfig.java
@@ -134,6 +134,22 @@ public class TestMetricsConfig {
}
/**
+ * Test the config value separated by delimiter
+ */
+ @Test public void testDelimiterConf() {
+ String filename = getTestFilename("test-metrics2-delimiter");
+ new ConfigBuilder().add("p1.foo", "p1foo1,p1foo2,p1foo3").save(filename);
+
+ MetricsConfig mc = MetricsConfig.create("p1", filename);
+ Configuration expected = new ConfigBuilder()
+ .add("foo", "p1foo1")
+ .add("foo", "p1foo2")
+ .add("foo", "p1foo3")
+ .config;
+ assertEq(expected, mc);
+ }
+
+ /**
* Return a test filename in the class path
* @param basename
* @return the filename
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]