directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1486298 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/filtering/ core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ core/src/main/java/org/apache/directory/server/...
Date Sat, 25 May 2013 08:13:00 GMT
Author: elecharny
Date: Sat May 25 08:12:59 2013
New Revision: 1486298

URL: http://svn.apache.org/r1486298
Log:
o Fixed many potential NPE detected by Sonar
o Fixed a bad list access on CursorList
o Initializing a default CacheService if none is given at startup

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/filtering/CursorList.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AddOperationContext.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/UnbindOperationContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
    directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/filtering/CursorList.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/filtering/CursorList.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/filtering/CursorList.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/filtering/CursorList.java
Sat May 25 08:12:59 2013
@@ -112,7 +112,7 @@ public class CursorList extends Abstract
             this.list = Collections.emptyList();
         }
 
-        listSize = list.size();
+        listSize = this.list.size();
 
         if ( ( start < 0 ) || ( start > listSize ) )
         {
@@ -135,7 +135,7 @@ public class CursorList extends Abstract
         this.end = end;
         this.searchContext = searchContext;
         index = start;
-        currentCursor = list.get( index );
+        currentCursor = this.list.get( index );
     }
 
 

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AddOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AddOperationContext.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AddOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AddOperationContext.java
Sat May 25 08:12:59 2013
@@ -23,6 +23,7 @@ package org.apache.directory.server.core
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapOperationErrorException;
 import org.apache.directory.api.ldap.model.message.AddRequest;
 import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.api.ldap.model.message.controls.ManageDsaIT;
@@ -118,6 +119,10 @@ public class AddOperationContext extends
         {
             setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.ADD
) );
         }
+        else
+        {
+            throw new LdapOperationErrorException( "No session to proceed the operation"
);
+        }
 
         entry = new ClonedServerEntry(
             new DefaultEntry( session.getDirectoryService().getSchemaManager(), addRequest.getEntry()
) );

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
Sat May 25 08:12:59 2013
@@ -29,6 +29,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.entry.Modification;
 import org.apache.directory.api.ldap.model.entry.ModificationOperation;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapOperationErrorException;
 import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
 import org.apache.directory.api.ldap.model.message.controls.ManageDsaIT;
@@ -96,6 +97,10 @@ public class ModifyOperationContext exte
         {
             setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.MODIFY
) );
         }
+        else
+        {
+            throw new LdapOperationErrorException( "Cannot proceed the operation with no
session" );
+        }
 
         modItems = ServerEntryUtils.toServerModification( modifyRequest.getModifications().toArray(
             new DefaultModification[0] ), session.getDirectoryService().getSchemaManager()
);

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/UnbindOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/UnbindOperationContext.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/UnbindOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/UnbindOperationContext.java
Sat May 25 08:12:59 2013
@@ -41,10 +41,7 @@ public class UnbindOperationContext exte
     {
         super( session, session.getEffectivePrincipal().getDn() );
 
-        if ( session != null )
-        {
-            setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND
) );
-        }
+        setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND
) );
     }
 
 
@@ -53,10 +50,7 @@ public class UnbindOperationContext exte
         super( session, session.getEffectivePrincipal().getDn() );
         setRequestControls( unbindRequest.getControls() );
 
-        if ( session != null )
-        {
-            setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND
) );
-        }
+        setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.UNBIND
) );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Sat May 25 08:12:59 2013
@@ -1792,11 +1792,14 @@ public class DefaultDirectoryService imp
             setDefaultInterceptorConfigurations();
         }
 
-        if ( cacheService != null )
+        if ( cacheService == null )
         {
-            cacheService.initialize( instanceLayout );
+            // Initialize a default cache service
+            cacheService = new CacheService();
         }
 
+        cacheService.initialize( instanceLayout );
+
         // Initialize the AP caches
         accessControlAPCache = new DnNode<AccessControlAdministrativePoint>();
         collectiveAttributeAPCache = new DnNode<CollectiveAttributeAdministrativePoint>();

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/GracefulShutdownHandler.java
Sat May 25 08:12:59 2013
@@ -247,21 +247,21 @@ public class GracefulShutdownHandler imp
                     LOG.warn( "Failed to sent NoD for client: " + session, e );
                 }
             }
-        }
 
-        // And close the connections when the NoDs are sent.
-        Iterator<IoSession> sessionIt = sessions.iterator();
+            // And close the connections when the NoDs are sent.
+            Iterator<IoSession> sessionIt = sessions.iterator();
 
-        for ( WriteFuture future : writeFutures )
-        {
-            try
+            for ( WriteFuture future : writeFutures )
             {
-                future.awaitUninterruptibly( 1000 );
-                sessionIt.next().close( true );
-            }
-            catch ( Exception e )
-            {
-                LOG.warn( "Failed to sent NoD.", e );
+                try
+                {
+                    future.awaitUninterruptibly( 1000 );
+                    sessionIt.next().close( true );
+                }
+                catch ( Exception e )
+                {
+                    LOG.warn( "Failed to sent NoD.", e );
+                }
             }
         }
     }

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
Sat May 25 08:12:59 2013
@@ -477,6 +477,8 @@ public class SearchRequestHandler extend
 
         boolean hasMoreEntry = cursor.next();
 
+        // We have some entry, move back to the first one, as we just moved forward 
+        // to get the first entry
         if ( hasMoreEntry )
         {
             cursor.previous();

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
Sat May 25 08:12:59 2013
@@ -69,7 +69,6 @@ import org.apache.directory.server.confi
 import org.apache.directory.server.config.beans.SaslMechHandlerBean;
 import org.apache.directory.server.config.beans.TcpTransportBean;
 import org.apache.directory.server.config.beans.TransportBean;
-import org.apache.directory.server.config.beans.UdpTransportBean;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.api.DirectoryService;
@@ -514,7 +513,7 @@ public class ServiceBuilder
         {
             transport = new TcpTransport();
         }
-        else if ( transportBean instanceof UdpTransportBean )
+        else
         {
             transport = new UdpTransport();
         }
@@ -972,13 +971,13 @@ public class ServiceBuilder
 
         // Relplication pinger thread sleep time
         ldapServer.setReplPingerSleepTime( ldapServerBean.getReplPingerSleep() );
-        
+
         // Enabled cipher suites
-        if( ldapServerBean.getEnabledCipherSuites() != null )
+        if ( ldapServerBean.getEnabledCipherSuites() != null )
         {
             ldapServer.setEnabledCipherSuites( ldapServerBean.getEnabledCipherSuites() );
         }
-        
+
         // The transports
         Transport[] transports = createTransports( ldapServerBean.getTransports() );
         ldapServer.setTransports( transports );

Modified: directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1486298&r1=1486297&r2=1486298&view=diff
==============================================================================
--- directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java
(original)
+++ directory/apacheds/trunk/service-osgi/src/main/java/org/apache/directory/server/ApacheDsService.java
Sat May 25 08:12:59 2013
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.commons.lang.time.DateUtils;
 import org.apache.directory.server.config.ConfigPartitionReader;
 import org.apache.directory.server.config.LdifConfigExtractor;
 import org.apache.directory.server.config.beans.ConfigBean;
@@ -52,31 +53,6 @@ import org.apache.directory.server.integ
 import org.apache.directory.server.kerberos.kdc.KdcServer;
 import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.ntp.NtpServer;
-import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
-import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
-import org.apache.directory.shared.ldap.model.entry.DefaultModification;
-import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Modification;
-import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.model.filter.ExprNode;
-import org.apache.directory.shared.ldap.model.filter.PresenceNode;
-import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.model.message.SearchScope;
-import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.schema.AttributeType;
-import org.apache.directory.shared.ldap.model.schema.AttributeTypeOptions;
-import org.apache.directory.shared.ldap.model.schema.SchemaManager;
-import org.apache.directory.shared.ldap.model.schema.registries.SchemaLoader;
-import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.CsnSyntaxChecker;
-import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.GeneralizedTimeSyntaxChecker;
-import org.apache.directory.shared.ldap.model.schema.syntaxCheckers.UuidSyntaxChecker;
-import org.apache.directory.shared.ldap.schemaextractor.SchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
-import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
-import org.apache.directory.shared.util.DateUtils;
-import org.apache.directory.shared.util.exception.Exceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -578,7 +554,10 @@ public class ApacheDsService
         }
 
         // We now have to stop the underlaying DirectoryService
-        ldapServer.getDirectoryService().shutdown();
+        if ( ldapServer != null )
+        {
+            ldapServer.getDirectoryService().shutdown();
+        }
     }
 
     private static final String BANNER_LDAP = "           _                     _       
  ____  ____   \n"



Mime
View raw message