Skip to content

Commit 3a69794

Browse files
author
zhourenjian
committed
Fixing bug on SimpleRPC's serializing null string and empty string
1 parent 2255b09 commit 3a69794

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleSerializable.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,17 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
659659
if (l3 > 0) {
660660
s = str.substring (index, index + l3);
661661
index += l3;
662+
} else if (l3 == 0) {
663+
s = "";
662664
}
663665
} else {
664666
var c5 = str.charCodeAt (index++);
665667
var l3 = c5 - baseChar;
666668
if (l3 > 0) {
667669
s = str.substring (index, index + l3);
668670
index += l3;
671+
} else if (l3 == 0) {
672+
s = "";
669673
} else if (l3 == -2) {
670674
var c6 = str.charCodeAt (index++);
671675
var l4 = c6 - baseChar;
@@ -707,6 +711,8 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
707711
if (l2 > 0) {
708712
s = str.substring (index, index + l2);
709713
index += l2;
714+
} else if (l2 == 0) {
715+
s = "";
710716
} else if (l2 == -2) {
711717
var c4 = str.charCodeAt(index++);
712718
var l3 = c4 - baseChar;
@@ -860,13 +866,17 @@ public boolean deserialize(final String str, int start) {
860866
if (l3 > 0) {
861867
ss[i] = str.substring(index, index + l3);
862868
index += l3;
869+
} else if (l3 == 0) {
870+
ss[i] = "";
863871
}
864872
} else {
865873
char c5 = str.charAt(index++);
866874
int l3 = c5 - baseChar;
867875
if (l3 > 0) {
868876
ss[i] = str.substring(index, index + l3);
869877
index += l3;
878+
} else if (l3 == 0) {
879+
ss[i] = "";
870880
} else if (l3 == -2) {
871881
char c6 = str.charAt(index++);
872882
int l4 = c6 - baseChar;
@@ -986,6 +996,8 @@ public boolean deserialize(final String str, int start) {
986996
if (l2 > 0) {
987997
s = str.substring(index, index + l2);
988998
index += l2;
999+
} else if (l2 == 0) {
1000+
s = "";
9891001
} else if (l2 == -2) {
9901002
char c4 = str.charAt(index++);
9911003
int l3 = c4 - baseChar;

0 commit comments

Comments
 (0)