Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -891,13 +891,6 @@
</description>
</property>

<property>
<name>io.bytes.per.checksum</name>
<value>512</value>
<description>The number of bytes per checksum. Must not be larger than
io.file.buffer.size.</description>
</property>

<property>
<name>io.skip.checksum.errors</name>
<value>false</value>
Expand Down Expand Up @@ -1097,13 +1090,6 @@
determine the host, port, etc. for a filesystem.</description>
</property>

<property>
<name>fs.default.name</name>
<value>file:///</value>
<description>Deprecated. Use (fs.defaultFS) property
instead</description>
</property>

<property>
<name>fs.trash.interval</name>
<value>0</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hadoop.conf;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -26,7 +27,9 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand All @@ -36,6 +39,8 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.hadoop.fs.CommonConfigurationKeys;

Expand All @@ -49,6 +54,8 @@
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.Uninterruptibles;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class TestConfigurationDeprecation {
private Configuration conf;
Expand Down Expand Up @@ -465,4 +472,30 @@ public void testGetPropertyBeforeDeprecetionsAreSet() throws Exception {
"Property should be accessible through new key");
}

@Test
public void testNoDeprecationsByDefault() throws Exception {
// Force initialization to make sure deprecations are recorded for later calls to isDeprecated.
new Configuration();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks good although it can't find all deprecated properties (e.g., io.bytes.per.checksum) cause the respective config classes are not loaded. I logged HADOOP-19769 which may be a more complete solution to avoid deprecated props in config files. Obviously, this PR is already good enough and we don't need to strictly wait for HADOOP-19769. If there is interest about HADOOP-19769 let me know and I will try to finalize the POC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, HADOOP-19769 looks like a good idea to me!


// This test directly parses the default XML configuration file to check for deprecated
// properties, bypassing normalization logic in the Configuration class that might hide them.
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
List<String> deprecatedProps = new ArrayList<>();

try (InputStream is = getClass().getResourceAsStream("/core-default.xml")) {
Document doc = db.parse(is);
NodeList props = doc.getElementsByTagName("name");
for (int i = 0; i < props.getLength(); ++i) {
String prop = props.item(i).getTextContent();
if (Configuration.isDeprecated(prop)) {
deprecatedProps.add(prop);
}
}
}

assertThat(deprecatedProps)
.as("By default, deprecated properties should be empty: %s", deprecatedProps)
.isEmpty();
}
}