Thomas Broyer has uploaded a new change for review.
https://gwt-review.googlesource.com/1770
Change subject: Proxy IDs have to be the same for a given proxy in the
response payload.
......................................................................
Proxy IDs have to be the same for a given proxy in the response payload.
More specifically, IDs of the operation messages have to be the same as
those of the IdMessages for the same proxy, so they're deserialized into
SimpleProxyIds having the same hashCode and comparing equal: if the ID
wasEphemeral, it has to contain both the client and server IDs in all
places, not only in operation messages.
Fixes issue 7900
Change-Id: I6c2ccbcfc67323e9e5cae214b0d101ddfc1a2298
---
M user/src/com/google/web/bindery/requestfactory/server/RequestState.java
M
user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git
a/user/src/com/google/web/bindery/requestfactory/server/RequestState.java
b/user/src/com/google/web/bindery/requestfactory/server/RequestState.java
index 93e7078..c1d698a 100644
---
a/user/src/com/google/web/bindery/requestfactory/server/RequestState.java
+++
b/user/src/com/google/web/bindery/requestfactory/server/RequestState.java
@@ -157,7 +157,8 @@
/**
* EntityCodex support. This method is identical to
* {@link IdFactory#getHistoryToken(SimpleProxyId)} except that it
- * base64-encodes the server ids.
+ * base64-encodes the server ids and adds client ids for stable ids
+ * that were ephemeral.
* <p>
* XXX: Merge this with AbstsractRequestContext's implementation
*/
@@ -172,6 +173,9 @@
ref.setStrength(Strength.EPHEMERAL);
ref.setClientId(stableId.getClientId());
} else {
+ if (stableId.wasEphemeral()) {
+ ref.setClientId(stableId.getClientId());
+ }
ref.setServerId(SimpleRequestProcessor.toBase64(stableId.getServerId()));
}
return AutoBeanCodex.encode(bean);
diff --git
a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java
b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java
index 90dcd71..caf6670 100644
---
a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java
+++
b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTest.java
@@ -16,6 +16,7 @@
package com.google.web.bindery.requestfactory.gwt.client;
import com.google.web.bindery.autobean.shared.AutoBeanCodex;
+import com.google.web.bindery.autobean.shared.AutoBeanUtils;
import com.google.web.bindery.requestfactory.shared.EntityProxy;
import com.google.web.bindery.requestfactory.shared.EntityProxyChange;
import com.google.web.bindery.requestfactory.shared.EntityProxyId;
@@ -271,6 +272,63 @@
assertEquals(2, handler.updateEventCount); // two bars persisted.
assertEquals(4, handler.totalEventCount);
finishTestAndReset();
+ }
+ });
+ }
+
+ /**
+ * See https://code.google.com/p/google-web-toolkit/issues/detail?id=7900
+ */
+ public void testCreatePersistCascadingAndReturnSelfEditWithReferences() {
+ delayTestFinish(DELAY_TEST_FINISH);
+
+ SimpleFooRequest context = simpleFooRequest();
+ SimpleFooProxy foo = context.create(SimpleFooProxy.class);
+ SimpleBarProxy bar = context.create(SimpleBarProxy.class);
+ foo.setBarField(bar);
+ Request<SimpleFooProxy> fooReq =
context.persistCascadingAndReturnSelf()
+ .using(foo).with("barField");
+ fooReq.fire(new Receiver<SimpleFooProxy>() {
+
+ @Override
+ public void onSuccess(SimpleFooProxy returned) {
+ assertTrue(AutoBeanUtils.getAutoBean(returned).isFrozen());
+
assertTrue(AutoBeanUtils.getAutoBean(returned.getBarField()).isFrozen());
+
+ simpleFooRequest().edit(returned);
+
+ finishTestAndReset();
+ }
+ });
+ }
+
+ /**
+ * See https://code.google.com/p/google-web-toolkit/issues/detail?id=7900
+ */
+ public void testCreateReferencePersistCascadingAndReturnSelfEdit() {
+ delayTestFinish(DELAY_TEST_FINISH);
+
+ simpleFooRequest().findSimpleFooById(1L).fire(new
Receiver<SimpleFooProxy>() {
+ @Override
+ public void onSuccess(SimpleFooProxy response) {
+ SimpleFooRequest context = simpleFooRequest();
+ SimpleFooProxy foo = context.edit(response);
+ SimpleBarProxy bar = context.create(SimpleBarProxy.class);
+ foo.setBarField(bar);
+ Request<SimpleFooProxy> fooReq =
context.persistCascadingAndReturnSelf()
+ .using(foo).with("barField");
+ fooReq.fire(new Receiver<SimpleFooProxy>() {
+
+ @Override
+ public void onSuccess(SimpleFooProxy returned) {
+ assertTrue(AutoBeanUtils.getAutoBean(returned).isFrozen());
+
assertTrue(AutoBeanUtils.getAutoBean(returned.getBarField()).isFrozen());
+
+ simpleFooRequest().edit(returned);
+
+ finishTestAndReset();
+ }
+ });
}
});
}
@@ -606,6 +664,9 @@
assertEquals(2, handler.totalEventCount);
checkStableIdEquals(foo, returned);
+
+ simpleFooRequest().edit(returned);
+
finishTestAndReset();
}
});
--
To view, visit https://gwt-review.googlesource.com/1770
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c2ccbcfc67323e9e5cae214b0d101ddfc1a2298
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Thomas Broyer <[email protected]>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors