From 7dd5c386611e31930e7ccfb83cb585df27696881 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 1 Mar 2012 04:24:35 +0000 Subject: Fixed a bug in java gats reading large strings over the network. --- java/com/xagasoft/gats/GatsObject.java | 5 +++-- java/com/xagasoft/gats/GatsString.java | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'java/com/xagasoft') diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java index fc3fb5a..47602b3 100644 --- a/java/com/xagasoft/gats/GatsObject.java +++ b/java/com/xagasoft/gats/GatsObject.java @@ -43,7 +43,8 @@ public abstract class GatsObject */ static GatsObject read( InputStream is ) throws java.io.IOException { - char type = (char)is.read(); + int b = is.read(); + char type = (char)b; GatsObject goRet = null; switch( type ) { @@ -77,7 +78,7 @@ public abstract class GatsObject return null; default: - throw new java.io.IOException("Invalid gats type discovered: " + (char)type ); + throw new java.io.IOException("Invalid gats type discovered: " + type + ", (" + b + ")" ); } goRet.read( is, type ); diff --git a/java/com/xagasoft/gats/GatsString.java b/java/com/xagasoft/gats/GatsString.java index e119aec..8e5c5c0 100644 --- a/java/com/xagasoft/gats/GatsString.java +++ b/java/com/xagasoft/gats/GatsString.java @@ -59,9 +59,13 @@ public class GatsString extends GatsObject void read( InputStream is, char cType ) throws java.io.IOException { - long lSize = GatsInteger.readPackedInt( is ); - aValue = new byte[(int)lSize]; - is.read( aValue ); + int lSize = (int)GatsInteger.readPackedInt( is ); + aValue = new byte[lSize]; + int lRead = 0; + do + { + lRead += is.read( aValue, lRead, lSize-lRead ); + } while( lRead < lSize ); } void write( OutputStream os ) throws java.io.IOException -- cgit v1.2.3