directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r291029 - /directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
Date Thu, 22 Sep 2005 22:56:50 GMT
Author: akarasulu
Date: Thu Sep 22 15:56:47 2005
New Revision: 291029

URL: http://svn.apache.org/viewcvs?rev=291029&view=rev
Log:
fixed bug where we were getting a class cast exception when performing compare operations

Modified:
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java?rev=291029&r1=291028&r2=291029&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
Thu Sep 22 15:56:47 2005
@@ -18,6 +18,7 @@
 
 
 import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.CompareRequest;
@@ -52,9 +53,10 @@
 
         try
         {
-            ServerLdapContext ctx = ( ServerLdapContext ) SessionRegistry.getSingleton().getLdapContext(
session, null, true );
+            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
+            ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
             LdapName name = new LdapName( req.getName() );
-            if ( ctx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
+            if ( newCtx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
             {
                 resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARETRUE );
             }
@@ -63,7 +65,7 @@
                 resp.getLdapResult().setResultCode( ResultCodeEnum.COMPAREFALSE );
             }
         }
-        catch ( NamingException e )
+        catch ( Exception e )
         {
             String msg = "failed to compare entry " + req.getName();
 
@@ -85,9 +87,12 @@
             resp.getLdapResult().setResultCode( code );
             resp.getLdapResult().setErrorMessage( msg );
 
-            if ( e.getResolvedName() != null )
+            if ( e instanceof NamingException )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                if ( ( ( NamingException ) e ).getResolvedName() != null )
+                {
+                    resp.getLdapResult().setMatchedDn( ( ( NamingException ) e ).getResolvedName().toString()
);
+                }
             }
 
             session.write( resp );



Mime
View raw message