You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2009/10/28 15:19:55 UTC

svn commit: r830555 - /felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java

Author: dsavage
Date: Wed Oct 28 14:19:55 2009
New Revision: 830555

URL: http://svn.apache.org/viewvc?rev=830555&view=rev
Log:
Handle null string value

Modified:
    felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java

Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java?rev=830555&r1=830554&r2=830555&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java Wed Oct 28 14:19:55 2009
@@ -93,17 +93,27 @@
     protected String readString() throws IOException
     {
         int l = in.readInt();
-        byte[] buf = new byte[l];
-        in.readFully( buf );
-        return new String(buf, ASCII);
+        if ( l == -1 ) {
+            return null;
+        }
+        else {
+            byte[] buf = new byte[l];
+            in.readFully( buf );
+            return new String(buf, ASCII);
+        }
     }
 
 
     protected void writeString( String str ) throws IOException
     {
-        byte[] buf = str.getBytes( ASCII );
-        out.writeInt( buf.length );
-        out.write( buf );
+        if ( str == null ) {
+            out.writeInt(-1);
+        }
+        else {
+            byte[] buf = str.getBytes( ASCII );
+            out.writeInt( buf.length );
+            out.write( buf );
+        }
     }