Reviewers: robertvawter,
Description:
Fix a corner case in getProxyId. Minor cleanup.
Patch by: amitmanjhi
Review by: robertvawter
Please review this at http://gwt-code-reviews.appspot.com/914801/show
Affected files:
M
user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
Index:
user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
===================================================================
---
user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
(revision 8851)
+++
user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
(working copy)
@@ -195,25 +195,21 @@
protected String getHistoryToken(EntityProxyId<?> proxyId,
ProxyToTypeMap recordToTypeMap) {
EntityProxyIdImpl<?> entityProxyId = (EntityProxyIdImpl<?>) proxyId;
- StringBuilder toReturn = new StringBuilder();
- boolean isFuture = false;
Object tokenId = entityProxyId.encodedId;
+ Object persistedId = tokenId;
if (entityProxyId.isFuture) {
// See if the associated entityproxy has been persisted in the
meantime
- Object persistedId =
futureToDatastoreMap.get(entityProxyId.encodedId);
- if (persistedId == null) {
- // Return a future token
- isFuture = true;
- } else {
- // Use the persisted id instead
+ persistedId = futureToDatastoreMap.get(entityProxyId.encodedId);
+ if (persistedId != null) {
tokenId = persistedId;
}
}
- toReturn = new StringBuilder();
+ StringBuilder toReturn = new StringBuilder();
toReturn.append(tokenId);
toReturn.append(HISTORY_TOKEN_SEPARATOR).append(
entityProxyId.schema.getToken());
- if (isFuture) {
+ if (persistedId == null) {
+ // attach the future tag.
toReturn.append(HISTORY_TOKEN_SEPARATOR).append(FUTURE_TOKEN);
}
return toReturn.toString();
@@ -236,7 +232,10 @@
}
String id = bits[ID_INDEX];
- Object futureId = datastoreToFutureMap.get(id, schema);
+ Object futureId = null;
+ if (!isFuture) {
+ futureId = datastoreToFutureMap.get(id, schema);
+ }
return new EntityProxyIdImpl<EntityProxy>(id, schema, isFuture,
futureId);
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors