Skip to content

Commit

Permalink
Make rpc serialization chunk size configurable (gwtproject#9578)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasterover9000 committed May 24, 2024
1 parent 89d06d6 commit c1d06a9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public final class ServerSerializationStreamWriter extends
* array literals.
*/
public static class LengthConstrainedArray {
public static final int MAXIMUM_ARRAY_LENGTH = 1 << 15;
private static final String POSTLUDE = "])";
private static final String PRELUDE = "].concat([";

private final StringBuffer buffer;
private final int maximumArrayLength = Integer.getInteger("gwt.rpc.maxPayloadChunkSize", 1 << 15);
private int count = 0;
private boolean needsComma = false;
private int total = 0;
Expand All @@ -68,8 +68,8 @@ public LengthConstrainedArray(int capacityGuess) {

public void addToken(CharSequence token) {
total++;
if (count++ == MAXIMUM_ARRAY_LENGTH) {
if (total == MAXIMUM_ARRAY_LENGTH + 1) {
if (count++ == maximumArrayLength) {
if (total == maximumArrayLength + 1) {
buffer.append(PRELUDE);
javascript = true;
} else {
Expand Down Expand Up @@ -106,7 +106,7 @@ public void setJavaScript(boolean javascript) {

@Override
public String toString() {
if (total > MAXIMUM_ARRAY_LENGTH) {
if (total > maximumArrayLength) {
return "[" + buffer.toString() + POSTLUDE;
} else {
return "[" + buffer.toString() + "]";
Expand Down

0 comments on commit c1d06a9

Please sign in to comment.