Buggy code:
@ InterfaceAudience . LimitedPrivate ( { "HDFS" , "MapReduce" } ) @ InterfaceStability . Unstable public class NetUtils { private static final Log LOG = LogFactory . getLog ( NetUtils . class ) ; private static Map < String , String > hostToResolved = new HashMap < String , String > ( ) ; private static final String FOR_MORE_DETAILS_SEE = "<seq2seq4repair_space>For<seq2seq4repair_space>more<seq2seq4repair_space>details<seq2seq4repair_space>see:<seq2seq4repair_space>" ; public static final String UNKNOWN_HOST = "(unknown)" ; public static final String HADOOP_WIKI = "http:////wiki.apache.org//hadoop//" ; public static SocketFactory getSocketFactory ( Configuration conf , Class < ? > clazz ) { } public static SocketFactory getDefaultSocketFactory ( Configuration conf ) { } public static SocketFactory getSocketFactoryFromProperty ( Configuration conf , String propValue ) { } public static InetSocketAddress createSocketAddr ( String target ) { } public static InetSocketAddress createSocketAddr ( String target , int defaultPort ) { } public static InetSocketAddress createSocketAddr ( String target , int defaultPort , String configName ) { } public static InetSocketAddress createSocketAddrForHost ( String host , int port ) { } public static URI getCanonicalUri ( URI uri , int defaultPort ) { } private static final ConcurrentHashMap < String , String > canonicalizedHostCache = new ConcurrentHashMap < String , String > ( ) ; private static String canonicalizeHost ( String host ) { String fqHost = NetUtils . canonicalizedHostCache . get ( host ) ; if ( fqHost == null ) { try { fqHost = SecurityUtil . getByName ( host ) . getHostName ( ) ; <START_BUG> NetUtils . canonicalizedHostCache . put ( host , fqHost ) ; <END_BUG> } catch ( UnknownHostException e ) { fqHost = host ; } } return fqHost ; } public static void addStaticResolution ( String host , String resolvedName ) { } public static String getStaticResolution ( String host ) { } public static List < String [ ] > getAllStaticResolutions ( ) { } public static InetSocketAddress getConnectAddress ( Server server ) { } public static InetSocketAddress getConnectAddress ( InetSocketAddress addr ) { } public static SocketInputWrapper getInputStream ( Socket socket ) throws IOException { } public static SocketInputWrapper getInputStream ( Socket socket , long timeout ) throws IOException { } public static OutputStream getOutputStream ( Socket socket ) throws IOException { } public static OutputStream getOutputStream ( Socket socket , long timeout ) throws IOException { } public static void connect ( Socket socket , SocketAddress address , int timeout ) throws IOException { } public static void connect ( Socket socket , SocketAddress endpoint , SocketAddress localAddr , int timeout ) throws IOException { } public static String normalizeHostName ( String name ) { } public static List < String > normalizeHostNames ( Collection < String > names ) { } public static void verifyHostnames ( String [ ] names ) throws UnknownHostException { } private static final Pattern ipPortPattern = Pattern . compile ( "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d+)?" ) ; public static String getHostNameOfIP ( String ipPort ) { } public static String getHostname ( ) { } public static String getHostPortString ( InetSocketAddress addr ) { } public static InetAddress getLocalInetAddress ( String host ) throws SocketException { } public static boolean isLocalAddress ( InetAddress addr ) { } public static IOException wrapException ( final String destHost , final int destPort , final String localHost , final int localPort , final IOException exception ) { } private static String see ( final String entry ) { } @ SuppressWarnings ( "unchecked" ) private static < T extends IOException > T wrapWithMessage ( T exception , String msg ) { } private static String getHostDetailsAsString ( final String destHost , final int destPort , final String localHost ) { } private static String quoteHost ( final String hostname ) { } public static boolean isValidSubnet ( String subnet ) { } private static void addMatchingAddrs ( NetworkInterface nif , SubnetInfo subnetInfo , List < InetAddress > addrs ) { } public static List < InetAddress > getIPs ( String subnet , boolean returnSubinterfaces ) { } public static int getFreeSocketPort ( ) { } }

Fix:
NetUtils . canonicalizedHostCache . putIfAbsent ( host , fqHost ) ;