You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by xk...@apache.org on 2019/04/22 15:22:21 UTC
[hadoop] branch branch-3.1 updated: HADOOP-16265. Fix bug causing
Configuration#getTimeDuration to use incorrect units when the default value
is used. Contributed by starphin.
This is an automated email from the ASF dual-hosted git repository.
xkrogen pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 9da70a1 HADOOP-16265. Fix bug causing Configuration#getTimeDuration to use incorrect units when the default value is used. Contributed by starphin.
9da70a1 is described below
commit 9da70a1b4b7196492991fa2857314e5bbf57db28
Author: Erik Krogen <xk...@apache.org>
AuthorDate: Mon Apr 22 08:16:57 2019 -0700
HADOOP-16265. Fix bug causing Configuration#getTimeDuration to use incorrect units when the default value is used. Contributed by starphin.
(cherry-picked from 1ddb48872f6a4985f4d0baadbb183899226cff68)
(cherry-picked from 28ff96f367ab2260666c2177980bce7c66e6dc57)
---
.../src/main/java/org/apache/hadoop/conf/Configuration.java | 2 +-
.../src/test/java/org/apache/hadoop/conf/TestConfiguration.java | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
index b91c9ef..f62a715 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
@@ -1810,7 +1810,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
TimeUnit defaultUnit, TimeUnit returnUnit) {
String vStr = get(name);
if (null == vStr) {
- return defaultValue;
+ return returnUnit.convert(defaultValue, defaultUnit);
} else {
return getTimeDurationHelper(name, vStr, defaultUnit, returnUnit);
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
index a8bca13..0703fe7 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java
@@ -1402,6 +1402,10 @@ public class TestConfiguration {
@Test
public void testTimeDuration() {
Configuration conf = new Configuration(false);
+
+ assertEquals(7000L,
+ conf.getTimeDuration("test.time.a", 7L, SECONDS, MILLISECONDS));
+
conf.setTimeDuration("test.time.a", 7L, SECONDS);
assertEquals("7s", conf.get("test.time.a"));
assertEquals(0L, conf.getTimeDuration("test.time.a", 30, MINUTES));
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org