Browse Source

Check for nulls.

Change-Id: I15144999a27f9f022bd0f27ba0967048e58da182
Reviewed-on: http://gerrit.dmdirc.com/2570
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1^0
Shane Mc Cormack 11 years ago
parent
commit
0f7a33fd23
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      src/com/dmdirc/parser/common/SRVRecord.java

+ 8
- 6
src/com/dmdirc/parser/common/SRVRecord.java View File

@@ -126,12 +126,14 @@ public class SRVRecord implements Comparable<SRVRecord> {
126 126
             env.put("java.naming.provider.url", "dns:");
127 127
             final Attribute attr = new InitialDirContext(env).getAttributes(host, new String [] { "SRV" }).get("SRV");
128 128
 
129
-            final NamingEnumeration ne = attr.getAll();
130
-            while (ne.hasMore()) {
131
-                try {
132
-                    final SRVRecord record = new SRVRecord((String)ne.next());
133
-                    result.add(record);
134
-                } catch (final NamingException nex) { /* Ignore if invalid. */ }
129
+            if (attr != null) {
130
+                final NamingEnumeration ne = attr.getAll();
131
+                while (ne.hasMore()) {
132
+                    try {
133
+                        final SRVRecord record = new SRVRecord((String)ne.next());
134
+                        result.add(record);
135
+                    } catch (final NamingException nex) { /* Ignore if invalid. */ }
136
+                }
135 137
             }
136 138
         } catch (final NamingException nex) { /* Ignore errors. */ }
137 139
 

Loading…
Cancel
Save