From a1cac20e95a2654d26ec700f2b99969bd890bb1e Mon Sep 17 00:00:00 2001 From: Baiqiang Zhao Date: Fri, 28 May 2021 22:24:48 +0800 Subject: [PATCH] HBASE-25928 TestHBaseConfiguration#testDeprecatedConfigurations is broken with Hadoop 3.3 (#3320) Signed-off-by: Wei-Chiu Chuang Signed-off-by: stack --- .../org/apache/hadoop/hbase/HBaseConfiguration.java | 5 +++++ .../apache/hadoop/hbase/TestHBaseConfiguration.java | 10 +++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java index d55cd5bf618..95cde018466 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java @@ -92,6 +92,11 @@ public class HBaseConfiguration extends Configuration { * HBASE-24667: This config hbase.regionserver.hostname.disable.master.reversedns will be * replaced by hbase.unsafe.regionserver.hostname.disable.master.reversedns. Keep the old config * keys here for backward compatibility. + *
+ * Note: Before Hadoop-3.3, we must call the addDeprecations method before creating the + * Configuration object to work correctly. After this bug is fixed in hadoop-3.3, there will be + * no order problem. + * @see HADOOP-15708 */ private static void addDeprecatedKeys() { Configuration.addDeprecations(new DeprecationDelta[]{ diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java index 3b98c50a4f1..3f0f3462e02 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java @@ -137,17 +137,13 @@ public class TestHBaseConfiguration { public void testDeprecatedConfigurations() { // Configuration.addDeprecations before create Configuration object Configuration.addDeprecations(new Configuration.DeprecationDelta[]{ - new Configuration.DeprecationDelta("hbase.deprecated.conf", "hbase.new.conf") + new Configuration.DeprecationDelta("hbase.deprecated.conf", "hbase.new.conf"), + new Configuration.DeprecationDelta("hbase.deprecated.conf2", "hbase.new.conf2") }); Configuration conf = HBaseConfiguration.create(); conf.addResource("hbase-deprecated-conf.xml"); assertEquals("1000", conf.get("hbase.new.conf")); - - // Configuration.addDeprecations after create Configuration object - Configuration.addDeprecations(new Configuration.DeprecationDelta[]{ - new Configuration.DeprecationDelta("hbase.deprecated.conf2", "hbase.new.conf2") - }); - assertNull(conf.get("hbase.new.conf2")); + assertEquals("1000", conf.get("hbase.new.conf2")); } private static class ReflectiveCredentialProviderClient {