You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/06/04 16:41:31 UTC

svn commit: r951423 - in /directory/shared/trunk: i18n/src/main/java/org/apache/directory/shared/i18n/ i18n/src/main/resources/org/apache/directory/shared/i18n/ ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/

Author: felixk
Date: Fri Jun  4 14:41:31 2010
New Revision: 951423

URL: http://svn.apache.org/viewvc?rev=951423&view=rev
Log:
Avoid unexpected NPEs

Modified:
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.java

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=951423&r1=951422&r2=951423&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Fri Jun  4 14:41:31 2010
@@ -619,6 +619,7 @@ public enum I18n
     ERR_04478_NO_VALUE_NOT_ALLOWED( "ERR_04478_NO_VALUE_NOT_ALLOWED" ),
     ERR_04479_INVALID_SYNTAX_VALUE( "ERR_04479_INVALID_SYNTAX_VALUE" ),
     ERR_04480_END_OF_STREAM( "ERR_04480_END_OF_STREAM" ),
+    ERR_04481_ENTRY_NULL_VALUE( "ERR_04481_ENTRY_NULL_VALUE" ),
 
     // ldap-constants
     ERR_05001( "ERR_05001" ),

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=951423&r1=951422&r2=951423&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Fri Jun  4 14:41:31 2010
@@ -603,6 +603,7 @@ ERR_04477_NO_VALID_AT_FOR_THIS_ID=Cannot
 ERR_04478_NO_VALUE_NOT_ALLOWED=Cannot create or add an Attribute with no value in it
 ERR_04479_INVALID_SYNTAX_VALUE= The value ''{0}'' does not respect the AttributeType ''{1}'' syntax
 ERR_04480_END_OF_STREAM=End of stream
+ERR_04481_ENTRY_NULL_VALUE=Entry can't be null
 
 # ldap-constants
 ERR_05001=Unknown AuthenticationLevel {0}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.java?rev=951423&r1=951422&r2=951423&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequestCodec.java Fri Jun  4 14:41:31 2010
@@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.exception.LdapException;
 
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
@@ -274,8 +275,13 @@ public class AddRequestCodec extends Lda
      *                    +--> ...
      *                    +--> 0x04 L7-m-n value
      */
-    protected int computeLengthProtocolOp()
+    protected int computeLengthProtocolOp() throws IllegalArgumentException
     {
+        if ( entry == null )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04481_ENTRY_NULL_VALUE ) );
+        }
+        
         // The entry
         addRequestLength = 1 + TLV.getNbBytes( DN.getNbBytes( entry.getDn() ) ) + DN.getNbBytes( entry.getDn() );
 
@@ -357,8 +363,13 @@ public class AddRequestCodec extends Lda
      * 
      * @param buffer The buffer where to put the PDU
      */
-    protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException
+    protected void encodeProtocolOp( ByteBuffer buffer ) throws EncoderException, IllegalArgumentException
     {
+        if ( entry == null )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04481_ENTRY_NULL_VALUE ) );
+        }
+        
         try
         {
             // The AddRequest Tag