--- old/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java 2011-07-27 17:18:27.161434900 -0700 +++ new/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java 2011-07-27 17:18:26.524371200 -0700 @@ -59,7 +59,7 @@ public Context getInitialContext(Hashtable env) throws NamingException { if (env == null) { - env = new Hashtable(5); + env = new Hashtable<>(5); } return urlToContext(getInitCtxUrl(env), env); } @@ -75,7 +75,7 @@ * components are overridden by "domain". */ public static DnsContext getContext(String domain, - DnsUrl[] urls, Hashtable env) + DnsUrl[] urls, Hashtable env) throws NamingException { String[] servers = serversForUrls(urls); @@ -95,7 +95,7 @@ ).isEmpty(); } - private static Context urlToContext(String url, Hashtable env) + private static Context urlToContext(String url, Hashtable env) throws NamingException { DnsUrl[] urls; @@ -212,7 +212,7 @@ * Reads environment to find URL(s) of initial context. * Default URL is "dns:". */ - private static String getInitCtxUrl(Hashtable env) { + private static String getInitCtxUrl(Hashtable env) { String url = (String) env.get(Context.PROVIDER_URL); return ((url != null) ? url : DEFAULT_URL); } @@ -223,34 +223,31 @@ * @param oneIsEnough return output once there exists one ok * @return the filtered list, all non-permitted input removed */ - private static List filterNameServers(List input, boolean oneIsEnough) { + private static List filterNameServers(List input, boolean oneIsEnough) { SecurityManager security = System.getSecurityManager(); if (security == null || input == null || input.isEmpty()) { return input; } else { - List output = new ArrayList(); - for (Object o: input) { - if (o instanceof String) { - String platformServer = (String)o; - int colon = platformServer.indexOf(':', - platformServer.indexOf(']') + 1); - - int p = (colon < 0) - ? DEFAULT_PORT - : Integer.parseInt( - platformServer.substring(colon + 1)); - String s = (colon < 0) - ? platformServer - : platformServer.substring(0, colon); - try { - security.checkConnect(s, p); - output.add(platformServer); - if (oneIsEnough) { - return output; - } - } catch (SecurityException se) { - continue; + List output = new ArrayList<>(); + for (String platformServer: input) { + int colon = platformServer.indexOf(':', + platformServer.indexOf(']') + 1); + + int p = (colon < 0) + ? DEFAULT_PORT + : Integer.parseInt( + platformServer.substring(colon + 1)); + String s = (colon < 0) + ? platformServer + : platformServer.substring(0, colon); + try { + security.checkConnect(s, p); + output.add(platformServer); + if (oneIsEnough) { + return output; } + } catch (SecurityException se) { + continue; } } return output;