[ 
https://issues.apache.org/jira/browse/HADOOP-11387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14252177#comment-14252177
 ] 

Jonathan Eagles commented on HADOOP-11387:
------------------------------------------

Posting warnings before the build artifacts are deleted. 

{quote}
Multithreaded correctness Warnings
Code    Warning
AT      Sequence of calls to java.util.concurrent.ConcurrentHashMap may not be 
atomic in org.apache.hadoop.net.NetUtils.canonicalizeHost(String)

 AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION: Sequence of calls to 
concurrent abstraction may not be atomic

This code contains a sequence of calls to a concurrent abstraction (such as a 
concurrent hash map). These calls will not be executed atomically. 
{quote}

{quote}
Bug type AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION (click for details)
In class org.apache.hadoop.net.NetUtils
In method org.apache.hadoop.net.NetUtils.canonicalizeHost(String)
Type java.util.concurrent.ConcurrentHashMap
Called method java.util.concurrent.ConcurrentHashMap.put(Object, Object)
At NetUtils.java:[line 291]
{quote}

> Simplify NetUtils#canonicalizeHost()
> ------------------------------------
>
>                 Key: HADOOP-11387
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11387
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Haohui Mai
>            Assignee: Li Lu
>         Attachments: HADOOP-11387-121514-1.patch, 
> HADOOP-11387-121514-2.patch, HADOOP-11387-121514.patch
>
>
> Currently {{NetUtils#canonicalizeHost}} uses a {{ConcurrentHashMap}} to cache 
> the canonicalized hostname.
> {code}
>   private static String canonicalizeHost(String host) {
>     // check if the host has already been canonicalized
>     String fqHost = canonicalizedHostCache.get(host);
>     if (fqHost == null) {
>       try {
>         fqHost = SecurityUtil.getByName(host).getHostName();
>         // slight race condition, but won't hurt
>         canonicalizedHostCache.put(host, fqHost);
>       } catch (UnknownHostException e) {
>         fqHost = host;
>       }
>     }
>     return fqHost;
>   }
> {code}
> The code triggers a findbugs warning. The cache is used for caching NN 
> resolution for the client-side {{FileSystem}} objects. In most of the use 
> cases there are at most one or two instances in the cache. This jira proposes 
> to eliminate the findbugs warnings and to simplify the code using 
> {{CacheMap}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to