Fix caching bug in ChangeResource

Since ChangeResource is used to return the permitted labels, a
change in group membership may change the permitted labels. This
means that the group membership should be used in computing the
ETag to send to the browser.  Otherwise, a browser will not see
a changed set of permissions on a change until something else
changes or the browser's cache is invalidated.

Change-Id: I3f29499334da6916a0292f4dab14908c7a08ce02
This commit is contained in:
Doug Kelly
2015-08-07 15:48:34 -05:00
committed by Doug Kelly
parent a17a9842cd
commit c679633fbc

View File

@@ -20,6 +20,7 @@ import com.google.common.hash.Hashing;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestResource.HasETag;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
@@ -66,6 +67,12 @@ public class ChangeResource implements RestResource, HasETag {
? ((IdentifiedUser) user).getAccountId().get()
: 0);
if (user.isIdentifiedUser()) {
for (AccountGroup.UUID uuid : user.getEffectiveGroups().getKnownGroups()) {
h.putBytes(uuid.get().getBytes());
}
}
byte[] buf = new byte[20];
ObjectId noteId;
try {