]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/util/DNSUtil.java
Merge "add: documentation to output classes"
[gigi.git] / src / org / cacert / gigi / util / DNSUtil.java
index e8a3a40d2edc179f3be6245badb51e9ad980f819..f1d5f9f3a86f9415aed483486ae857c5764c9dc2 100644 (file)
@@ -15,8 +15,6 @@ public class DNSUtil {
     static {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
-        // env.put(Context.AUTHORITATIVE, "true");
-        // env.put(Context.PROVIDER_URL, "dns://ns.dyn.dogcraft.de");
         try {
             context = new InitialDirContext(env);
         } catch (NamingException e) {
@@ -38,12 +36,16 @@ public class DNSUtil {
         env.put(Context.AUTHORITATIVE, "true");
         env.put(Context.PROVIDER_URL, "dns://" + server);
         InitialDirContext context = new InitialDirContext(env);
+        try {
 
-        Attributes dnsLookup = context.getAttributes(name, new String[] {
-            "TXT"
-        });
+            Attributes dnsLookup = context.getAttributes(name, new String[] {
+                "TXT"
+            });
+            return extractTextEntries(dnsLookup.get("TXT"));
+        } finally {
+            context.close();
+        }
 
-        return extractTextEntries(dnsLookup.get("TXT"));
     }
 
     private static String[] extractTextEntries(Attribute nsRecords) throws NamingException {