directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 37037 - in incubator/directory/ldap/trunk/common/src: java/org/apache/ldap/common/message test/org/apache/ldap/common/message
Date Wed, 25 Aug 2004 18:21:31 GMT
Author: akarasulu
Date: Wed Aug 25 11:21:31 2004
New Revision: 37037

Modified:
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LdapResultImpl.java
   incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/LdapResultImplTest.java
Log:
Caused a bug when we set default's in the result errorMessage and matchedDn
fields.  We have reverted to the old way with null defaults but have braced for
possible side effects.

Also note that although for errorMessage both "" and null are considered 
equivalent this is not the same for the matchedDn feild because "" is 
considered a valid DN.  So "" does not really correspond to null in this
case.


Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LdapResultImpl.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LdapResultImpl.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/LdapResultImpl.java
Wed Aug 25 11:21:31 2004
@@ -230,11 +230,11 @@
     extends AbstractLockable implements LdapResult
 {
     /** Lowest matched entry Dn - defaults to empty string */
-    private String matchedDn = "";
+    private String matchedDn;
     /** Referral associated with this LdapResult if the errorCode is REFERRAL */
     private Referral referral;
     /** Decriptive error message - defaults to empty string */
-    private String errorMessage = "";
+    private String errorMessage;
     /** Resultant operation error code - defaults to SUCCESS */
     private ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS;
 
@@ -428,12 +428,35 @@
             return false;
         }
 
-        if ( ! errorMessage.equals( result.getErrorMessage() ) )
+
+        // Handle Error Messages where "" is considered equivalent to null
+        String errMsg0 = errorMessage;
+        String errMsg1 = result.getErrorMessage();
+
+        if ( errMsg0 == null )
+        {
+            errMsg0 = "";
+        }
+
+        if ( errMsg1 == null )
+        {
+            errMsg1 = "";
+        }
+
+        if ( ! errMsg0.equals( errMsg1 ) )
         {
             return false;
         }
 
-        if ( ! this.matchedDn.equals( result.getMatchedDn() ) )
+
+        if ( matchedDn != null )
+        {
+            if ( ! matchedDn.equals( result.getMatchedDn() ) )
+            {
+                return false;
+            }
+        }
+        else if ( result.getMatchedDn() != null ) // one is null other is not
         {
             return false;
         }

Modified: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/LdapResultImplTest.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/LdapResultImplTest.java
(original)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/LdapResultImplTest.java
Wed Aug 25 11:21:31 2004
@@ -89,7 +89,7 @@
 
             public String getMatchedDn()
             {
-                return "";
+                return null;
             }
 
             public void setMatchedDn( String a_dn )
@@ -98,7 +98,7 @@
 
             public String getErrorMessage()
             {
-                return "";
+                return null;
             }
 
             public void setErrorMessage( String a_errorMessage )

Mime
View raw message