Marcono1234 created HADOOP-17761:
------------------------------------

             Summary: Replace usage of Hashtable and 
ConcurrentHashMap.contains(Object)
                 Key: HADOOP-17761
                 URL: https://issues.apache.org/jira/browse/HADOOP-17761
             Project: Hadoop Common
          Issue Type: Bug
            Reporter: Marcono1234


The Hadoop project and its subprojects use in a few places 
[{{Hashtable.contains(Object)}}|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Hashtable.html#contains(java.lang.Object)]
 (or the inherited {{Properties.contains(Object)}}) and 
[{{ConcurrentHashMap.contains(Object)}}|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.html#contains(java.lang.Object)].
 They originate from the old {{Hashtable}} class. The {{java.util.Map}} 
interface added {{containsValue(Object)}}, which behaves exactly the same, but 
has the major advantage that its name makes it more clear what the method 
actually does.

In fact some usage of {{contains(Object)}} by Hadoop is erroneous and results 
in incorrect behavior, it seems the author should have used 
{{containsKey(Object)}} instead.

Affected:
- 
[{{Configuration.setDeprecatedProperties()}}|https://github.com/apache/hadoop/blob/35e4c31fff9946d35a3543481585031558e9f5d5/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java#L692]
Seems to be a bug, should use {{containsKey(Object)}}; looks like this was also 
reported in HADOOP-15468
- {{DFSClient.isDeadNode(...)}}: 
[here|https://github.com/apache/hadoop/blob/35e4c31fff9946d35a3543481585031558e9f5d5/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L3400]
 and 
[here|https://github.com/apache/hadoop/blob/35e4c31fff9946d35a3543481585031558e9f5d5/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L3404]
Not sure if correct usage, should use either {{containsKey(Object)}} or 
{{containsValue(Object)}}
- 
[{{RestClientBindings.bind(...)}}|https://github.com/apache/hadoop/blob/35e4c31fff9946d35a3543481585031558e9f5d5/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/http/RestClientBindings.java#L152]
Not sure if correct usage, should use either {{containsKey(Object)}} or 
{{containsValue(Object)}}
- 
[{{TestableFederationClientInterceptor.registerBadSubCluster(...)}}|https://github.com/apache/hadoop/blob/35e4c31fff9946d35a3543481585031558e9f5d5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestableFederationClientInterceptor.java#L113]
Likely a bug, should use {{containsKey(Object)}}; also detected by [LGTM / 
CodeQL|https://lgtm.com/projects/g/apache/hadoop/snapshot/0c9c811fe5bfda548596b99d7c111994bf66a66b/files/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestableFederationClientInterceptor.java?sort=name&dir=ASC&mode=heatmap#L113]




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-dev-h...@hadoop.apache.org

Reply via email to