You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2017/08/30 15:59:13 UTC

svn commit: r1806703 - /directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java

Author: elecharny
Date: Wed Aug 30 15:59:12 2017
New Revision: 1806703

URL: http://svn.apache.org/viewvc?rev=1806703&view=rev
Log:
Added some check for Attribute which value is null

Modified:
    directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java

Modified: directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1806703&r1=1806702&r2=1806703&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original)
+++ directory/apacheds/branches/apacheds-value/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Wed Aug 30 15:59:12 2017
@@ -247,9 +247,16 @@ public class ConfigPartitionReader
         {
             return;
         }
-
+        
+        
         Value value = fieldAttr.get();
-        String valueStr = value.getValue();
+        String valueStr = ""; 
+        
+        if ( value != null )
+        {
+            valueStr = value.getValue();
+        }
+
         Class<?> type = beanField.getType();
 
         // Process the value accordingly to its type.
@@ -451,15 +458,31 @@ public class ConfigPartitionReader
         // Get the entry attribute for this attribute type
         Attribute attribute = entry.get( attributeTypeName );
 
-        if ( ( attribute != null ) && ( attribute.size() > 0 ) )
+        if ( attribute != null )
         {
-            if ( !isMultiple( field.getType() ) )
+            if ( attribute.size() > 0 )
+            {
+                if ( !isMultiple( field.getType() ) )
+                {
+                    readSingleValueField( bean, field, attribute );
+                }
+                else
+                {
+                    readMultiValuedField( bean, field, attribute );
+                }
+            }
+            else if ( attribute.size() == 0 )
             {
+                // No value ? May be valid
                 readSingleValueField( bean, field, attribute );
             }
-            else
+            else if ( mandatory )
             {
-                readMultiValuedField( bean, field, attribute );
+                // the requested element is mandatory so let's throw an exception
+                String message = "No value was configured for entry with DN '"
+                    + entry.getDn() + "' and attribute type '" + attributeTypeName + "'.";
+                LOG.error( message );
+                throw new ConfigurationException( message );
             }
         }
         else