src/share/classes/com/sun/jndi/dns/DnsContextFactory.java

Print this page

        

@@ -57,11 +57,11 @@
     private static final int DEFAULT_PORT = 53;
 
 
     public Context getInitialContext(Hashtable<?,?> env) throws NamingException {
         if (env == null) {
-            env = new Hashtable(5);
+            env = new Hashtable<>(5);
         }
         return urlToContext(getInitCtxUrl(env), env);
     }
 
     public static DnsContext getContext(String domain,

@@ -73,11 +73,11 @@
     /*
      * "urls" are used to determine the servers, but any domain
      * 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);
         DnsContext ctx = getContext(domain, servers, env);
         if (platformServersUsed(urls)) {

@@ -93,11 +93,11 @@
         return !filterNameServers(
                     ResolverConfiguration.open().nameservers(), true
                 ).isEmpty();
     }
 
-    private static Context urlToContext(String url, Hashtable env)
+    private static Context urlToContext(String url, Hashtable<?,?> env)
             throws NamingException {
 
         DnsUrl[] urls;
         try {
             urls = DnsUrl.fromList(url);

@@ -210,30 +210,28 @@
 
     /*
      * 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);
     }
 
     /**
      * Removes any DNS server that's not permitted to access
      * @param input the input server[:port] list, must not be null
      * @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<String> filterNameServers(List<String> 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;
+            List<String> output = new ArrayList<>();
+            for (String platformServer: input) {
                     int colon = platformServer.indexOf(':',
                             platformServer.indexOf(']') + 1);
 
                     int p = (colon < 0)
                         ? DEFAULT_PORT

@@ -250,10 +248,9 @@
                         }
                     } catch (SecurityException se) {
                         continue;
                     }
                 }
-            }
             return output;
         }
     }
 }