directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r809205 - in /directory/shared/branches/shared-schema: ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/ ldap/src/main/java/org/apache/directory/shared/ldap/schema/ ldap/src/main/java/org/apache/directory/shar...
Date Sat, 29 Aug 2009 22:17:24 GMT
Author: akarasulu
Date: Sat Aug 29 22:17:24 2009
New Revision: 809205

URL: http://svn.apache.org/viewvc?rev=809205&view=rev
Log:
fixed bug in hashCode() causing NPE due to inclusion of single null value in list of names
(aliases)

Modified:
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java?rev=809205&r1=809204&r2=809205&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
Sat Aug 29 22:17:24 2009
@@ -396,6 +396,7 @@
             LdifEntry entry = reader.next();
             LdapComparator<?> comparator = 
                 factory.getLdapComparator( entry.getEntry(), registries );
+            comparator.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() );
             registries.getComparatorRegistry().register( comparator );
         }
     }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java?rev=809205&r1=809204&r2=809205&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
(original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
Sat Aug 29 22:17:24 2009
@@ -51,6 +51,8 @@
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.DefaultSchema;
 import org.apache.directory.shared.ldap.util.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -61,6 +63,12 @@
  */
 public class SchemaEntityFactory
 {
+	/** Slf4j logger */
+	private final static Logger LOG = LoggerFactory.getLogger( SchemaEntityFactory.class );
+
+	/** for fast debug checks */
+	private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+	
     /** Used for looking up the setRegistries(Registries) method */
     private final static Class<?>[] parameterTypes = new Class[] { Registries.class
};
     
@@ -202,14 +210,22 @@
         LdapComparator<?> comparator = null;
         Class<?> clazz = null;
          
-        if ( bytecode == null ) 
+        try
         {
-            clazz = Class.forName( className );
+	        if ( bytecode == null ) 
+	        {
+	            clazz = Class.forName( className );
+	        }
+	        else
+	        {
+	            classLoader.setAttribute( bytecode );
+	            clazz = classLoader.loadClass( className );
+	        }
         }
-        else
+        catch ( Exception e )
         {
-            classLoader.setAttribute( bytecode );
-            clazz = classLoader.loadClass( className );
+        	LOG.error( "Failed to load class from LDIF bytecode from schemaObject {}", oid,
e );
+        	throw e;
         }
         
         comparator = ( LdapComparator<?> ) clazz.newInstance();
@@ -258,7 +274,7 @@
         }
         
         String className = entry.get( MetaSchemaConstants.M_FQCN_AT ).get().getString();
-        return getLdapComparator( entry.get( MetaSchemaConstants.M_OID_AT ).toString(), 
+        return getLdapComparator( entry.get( MetaSchemaConstants.M_OID_AT ).getString(),

             className, entry.get( MetaSchemaConstants.M_BYTECODE_AT ), targetRegistries );
     }
     
@@ -339,7 +355,21 @@
      */
     private void injectRegistries( Object obj, Registries targetRegistries ) throws Exception
     {
-        Method method = obj.getClass().getMethod( "setRegistries", parameterTypes );
+        Method method = null;
+        
+        try
+        {
+        	method = obj.getClass().getMethod( "setRegistries", parameterTypes );
+        }
+        catch ( NoSuchMethodException e )
+        {
+        	if ( IS_DEBUG )
+        	{
+        		LOG.debug( obj.getClass() + " has no setRegistries() method." );
+        	}
+        	
+        	return;
+        }
         
         if ( method == null )
         {

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java?rev=809205&r1=809204&r2=809205&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
Sat Aug 29 22:17:24 2009
@@ -116,7 +116,11 @@
         isReadOnly = false;
         extensions = new HashMap<String, List<String>>();
         names = new ArrayList<String>();
-        names.add( oid );
+        
+        if ( oid != null )
+        {
+        	names.add( oid );
+        }
     }
     
     
@@ -133,7 +137,6 @@
         isReadOnly = false;
         extensions = new HashMap<String, List<String>>();
         names = new ArrayList<String>();
-        names.add( oid );
     }
     
     
@@ -215,7 +218,10 @@
         {
             for ( String name : names )
             {
-                this.names.add( name );
+            	if ( name != null )
+            	{
+            		this.names.add( name );
+            	}
             }
         }
     }
@@ -228,13 +234,21 @@
      */
     public void setNames( List<String> names )
     {
+    	if ( names == null )
+    	{
+    		return;
+    	}
+    	
         if ( ! isReadOnly )
         {
             this.names = new ArrayList<String>( names.size() );
             
             for ( String name:names )
             {
-                this.names.add( name );
+            	if ( name != null )
+            	{
+            		this.names.add( name );
+            	}
             }
         }
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java?rev=809205&r1=809204&r2=809205&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java
Sat Aug 29 22:17:24 2009
@@ -98,4 +98,19 @@
 
         return comparator.compare( n1, n2 );
     }
+    
+    
+    /**
+     * Makes sure we update the oid property of the contained normalizer and 
+     * comparator.
+     * 
+     * @param oid the object identifier
+     */
+    @Override
+    public void setOid( String oid )
+    {
+    	super.setOid( oid );
+    	normalizer.setOid( oid );
+    	comparator.setOid( oid );
+    }    
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java?rev=809205&r1=809204&r2=809205&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
Sat Aug 29 22:17:24 2009
@@ -212,7 +212,7 @@
         
         if ( LOG.isDebugEnabled() )
         {
-            LOG.debug( "registered {} for OID {}", schemaObject, oid );
+            LOG.debug( "registered " + schemaObject.getName() + " for OID {}", oid );
         }
         
         // And register the oid -> schemaObject relation



Mime
View raw message