directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r291505 - /directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Date Mon, 26 Sep 2005 01:12:00 GMT
Author: elecharny
Date: Sun Sep 25 18:11:55 2005
New Revision: 291505

URL: http://svn.apache.org/viewcvs?rev=291505&view=rev
Log:
Fixed a NPE

Modified:
    directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java

Modified: directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
URL: http://svn.apache.org/viewcvs/directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java?rev=291505&r1=291504&r2=291505&view=diff
==============================================================================
--- directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
(original)
+++ directory/asn1/branches/asn1-NameComponent/ber-new/src/java/main/org/apache/asn1new/ber/tlv/Value.java
Sun Sep 25 18:11:55 2005
@@ -251,23 +251,29 @@
 
         try 
         {
-            buffer.put( UniversalTag.OCTET_STRING_TAG );
-            byte[] value = null;
-            
             try 
             {
-            	value = string.getBytes("UTF-8");
-            } 
-            catch (UnsupportedEncodingException uee)
+                buffer.put( UniversalTag.OCTET_STRING_TAG );
+
+                if ( StringUtils.isEmpty( string ) )
+                {
+                    buffer.put( (byte)0x00 );
+                }
+                else
+                {
+                    byte[] value = string.getBytes( "UTF-8" );
+                    
+                    buffer.put( Length.getBytes( value.length ) );
+                    buffer.put( value );
+                }
+            }
+            catch ( BufferOverflowException boe )
             {
-            	throw new EncoderException("The Value encoding is not UTF-8");
+                throw new EncoderException("The PDU buffer size is too small !"); 
             }
-            
-            buffer.put( Length.getBytes( value.length ) );
-    
-            if ( value.length != 0 )
+            catch ( UnsupportedEncodingException uee )
             {
-                buffer.put( value );
+                throw new EncoderException("The String is not UTF-8 encoded !"); 
             }
         }
         catch ( BufferOverflowException boe )



Mime
View raw message