Skip to content

Commit 93ac00e

Browse files
committed
Fixed bug that on receiving part of a SimpleSerializable object in pipe,
it throws exceptions instead of continue reading more data from pipe
1 parent 4185bb9 commit 93ac00e

File tree

2 files changed

+103
-60
lines changed

2 files changed

+103
-60
lines changed

sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeRequest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,10 @@ public void onLoaded() {
806806
parseReceivedBytes(bytes);
807807
} catch (RuntimeException e) { // invalid simple format
808808
int length = bytes.length;
809-
if (length < 100) {
809+
if (length < 1024) {
810810
System.out.println("[ERROR]: " + new String(bytes));
811811
} else {
812-
System.out.println("[ERROR]: " + new String(bytes, 0, 100) + " ..");
812+
System.out.println("[ERROR]: " + new String(bytes, 0, 1024) + " ...");
813813
}
814814
throw e;
815815
}
@@ -952,12 +952,15 @@ public boolean receiving(ByteArrayOutputStream baos, byte b[], int off, int len)
952952
int resetIndex = 0;
953953
try {
954954
resetIndex = parseReceivedBytes(bytes);
955-
} catch (RuntimeException e) { // invalid simple format
955+
} catch (RuntimeException e) { // not enough data, invalid simple format, array size too large
956+
if (SimpleSerializable.EXCEPTION_NOT_ENOUGH_DATA.equals(e.getMessage())) {
957+
return true;
958+
}
956959
int length = bytes.length;
957-
if (length < 100) {
960+
if (length < 1024) {
958961
System.out.println("[ERROR]: " + new String(bytes));
959962
} else {
960-
System.out.println("[ERROR]: " + new String(bytes, 0, 100) + " ..");
963+
System.out.println("[ERROR]: " + new String(bytes, 0, 1024) + " ...");
961964
}
962965
throw e;
963966
}

0 commit comments

Comments
 (0)