jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java
changeset 10596 39b3a979e600
parent 6112 b9d1b10c662c
child 23333 b0af2c7c8c91
equal deleted inserted replaced
10595:c5be3e19fbab 10596:39b3a979e600
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   138             }
   138             }
   139 
   139 
   140             // create new soft reference to our thread context
   140             // create new soft reference to our thread context
   141             //
   141             //
   142             thrCtxt = new ThreadContext(dirCtxt, nsList);
   142             thrCtxt = new ThreadContext(dirCtxt, nsList);
   143             contextRef.set(new SoftReference(thrCtxt));
   143             contextRef.set(new SoftReference<ThreadContext>(thrCtxt));
   144         }
   144         }
   145 
   145 
   146         return thrCtxt.dirContext();
   146         return thrCtxt.dirContext();
   147     }
   147     }
   148 
   148 
   191         try {
   191         try {
   192             while (ne.hasMoreElements()) {
   192             while (ne.hasMoreElements()) {
   193                 Attribute attr = ne.next();
   193                 Attribute attr = ne.next();
   194                 String attrID = attr.getID();
   194                 String attrID = attr.getID();
   195 
   195 
   196                 for (NamingEnumeration e = attr.getAll(); e.hasMoreElements();) {
   196                 for (NamingEnumeration<?> e = attr.getAll(); e.hasMoreElements();) {
   197                     String addr = (String)e.next();
   197                     String addr = (String)e.next();
   198 
   198 
   199                     // for canoncical name records do recursive lookup
   199                     // for canoncical name records do recursive lookup
   200                     // - also check for CNAME loops to avoid stack overflow
   200                     // - also check for CNAME loops to avoid stack overflow
   201 
   201 
   231 
   231 
   232         // default domain
   232         // default domain
   233         String domain = AccessController.doPrivileged(
   233         String domain = AccessController.doPrivileged(
   234             new GetPropertyAction("sun.net.spi.nameservice.domain"));
   234             new GetPropertyAction("sun.net.spi.nameservice.domain"));
   235         if (domain != null && domain.length() > 0) {
   235         if (domain != null && domain.length() > 0) {
   236             domainList = new LinkedList();
   236             domainList = new LinkedList<String>();
   237             domainList.add(domain);
   237             domainList.add(domain);
   238         }
   238         }
   239 
   239 
   240         // name servers
   240         // name servers
   241         String nameservers = AccessController.doPrivileged(
   241         String nameservers = AccessController.doPrivileged(
   280             ctx = getTemporaryContext();
   280             ctx = getTemporaryContext();
   281         } catch (NamingException nx) {
   281         } catch (NamingException nx) {
   282             throw new Error(nx);
   282             throw new Error(nx);
   283         }
   283         }
   284 
   284 
   285         ArrayList results = null;
   285         ArrayList<String> results = null;
   286         UnknownHostException uhe = null;
   286         UnknownHostException uhe = null;
   287 
   287 
   288         // If host already contains a domain name then just look it up
   288         // If host already contains a domain name then just look it up
   289         if (host.indexOf('.') >= 0) {
   289         if (host.indexOf('.') >= 0) {
   290             try {
   290             try {
   363          */
   363          */
   364         assert results.size() > 0;
   364         assert results.size() > 0;
   365         InetAddress[] addrs = new InetAddress[results.size()];
   365         InetAddress[] addrs = new InetAddress[results.size()];
   366         int count = 0;
   366         int count = 0;
   367         for (int i=0; i<results.size(); i++) {
   367         for (int i=0; i<results.size(); i++) {
   368             String addrString = (String)results.get(i);
   368             String addrString = results.get(i);
   369             byte addr[] = IPAddressUtil.textToNumericFormatV4(addrString);
   369             byte addr[] = IPAddressUtil.textToNumericFormatV4(addrString);
   370             if (addr == null) {
   370             if (addr == null) {
   371                 addr = IPAddressUtil.textToNumericFormatV6(addrString);
   371                 addr = IPAddressUtil.textToNumericFormatV6(addrString);
   372             }
   372             }
   373             if (addr != null) {
   373             if (addr != null) {