Revision: 5980 Author: [email protected] Date: Thu Aug 20 05:48:36 2009 Log: Fix potential error scenario where the web-mode backref ident can be determined incorrectly.
Patch by: bobv Review by: rjrjr http://code.google.com/p/google-web-toolkit/source/detail?r=5980 Modified: /trunk/user/src/com/google/gwt/rpc/client/impl/CommandClientSerializationStreamReader.java /trunk/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java ======================================= --- /trunk/user/src/com/google/gwt/rpc/client/impl/CommandClientSerializationStreamReader.java Mon Jul 6 16:17:17 2009 +++ /trunk/user/src/com/google/gwt/rpc/client/impl/CommandClientSerializationStreamReader.java Thu Aug 20 05:48:36 2009 @@ -29,6 +29,12 @@ public class CommandClientSerializationStreamReader implements SerializationStreamReader { + /** + * An identifier in the payload evaluation context that is used to hold + * backreferences. + */ + public static final String BACKREF_IDENT = "_"; + private static native JsArray<JavaScriptObject> eval(String payload) /*-{ return eval(payload); }-*/; @@ -80,7 +86,7 @@ public void prepareToRead(String js) throws RemoteException { try { - payload = eval("(function(){var _={};" + js + "})()"); + payload = eval("(function(){var " + BACKREF_IDENT + "={};" + js + "})()"); assert payload != null : "Payload evaluated to null"; } catch (JavaScriptException e) { throw new IncompatibleRemoteServiceException( ======================================= --- /trunk/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java Tue Jul 21 11:59:13 2009 +++ /trunk/user/src/com/google/gwt/rpc/server/WebModePayloadSink.java Thu Aug 20 05:48:36 2009 @@ -15,6 +15,8 @@ */ package com.google.gwt.rpc.server; +import static com.google.gwt.rpc.client.impl.CommandClientSerializationStreamReader.BACKREF_IDENT; + import com.google.gwt.rpc.client.ast.ArrayValueCommand; import com.google.gwt.rpc.client.ast.BooleanValueCommand; import com.google.gwt.rpc.client.ast.ByteValueCommand; @@ -862,7 +864,6 @@ } private final ClientOracle clientOracle; - private final String backRefIdent; private boolean finished = false; private final OutputStream out; private final Map<ValueCommand, byte[]> valueBackRefs = new HashMap<ValueCommand, byte[]>(); @@ -873,7 +874,6 @@ public WebModePayloadSink(ClientOracle clientOracle, OutputStream out) { this.clientOracle = clientOracle; this.out = out; - backRefIdent = clientOracle.createUnusedIdent("_"); } @Override @@ -920,7 +920,7 @@ if (toReturn == null) { if (freeBackRefs.isEmpty()) { int idx = valueBackRefs.size(); - toReturn = getBytes(backRefIdent + "._" + toReturn = getBytes(BACKREF_IDENT + "._" + Integer.toString(idx, Character.MAX_RADIX)); } else { toReturn = freeBackRefs.pop(); --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
