directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r292332 - /directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
Date Wed, 28 Sep 2005 22:09:56 GMT
Author: erodriguez
Date: Wed Sep 28 15:09:52 2005
New Revision: 292332

URL: http://svn.apache.org/viewcvs?rev=292332&view=rev
Log:
Added logic to handle null attributes and prevent NPE's.

Modified:
    directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java

Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java?rev=292332&r1=292331&r2=292332&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
Wed Sep 28 15:09:52 2005
@@ -19,6 +19,7 @@
 import javax.naming.Name;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
@@ -101,10 +102,12 @@
     {
         ResourceRecordModifier modifier = new ResourceRecordModifier();
 
-        String dnsName = (String) attrs.get( DnsAttribute.NAME ).get();
-        String dnsType = (String) attrs.get( DnsAttribute.TYPE ).get();
-        String dnsClass = (String) attrs.get( DnsAttribute.CLASS ).get();
-        String dnsTtl = (String) attrs.get( DnsAttribute.TTL ).get();
+        Attribute attr;
+
+        String dnsName = ( attr = attrs.get( DnsAttribute.NAME ) ) != null ? (String) attr.get()
: null;
+        String dnsType = ( attr = attrs.get( DnsAttribute.TYPE ) ) != null ? (String) attr.get()
: null;
+        String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? (String) attr.get()
: null;
+        String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? (String) attr.get()
: null;
 
         modifier.setDnsName( dnsName );
         modifier.setDnsType( RecordType.getTypeByName( dnsType ) );



Mime
View raw message