Expose the account id from current session

The session value contains the account id [val.getAccountId()] and it
can be of great value to access that information directly without
having to necessarily inject the Provider<CurrentUser>.

Less CPU cycles and less injections needed for Servlet filters.

Change-Id: I47cc19b1aa32c897f7ade5a96c59161093543f39
This commit is contained in:
Luca Milanesio
2016-05-12 17:53:18 +01:00
parent ad2d416cf7
commit fd8b3c7c18
2 changed files with 7 additions and 0 deletions

View File

@@ -137,6 +137,11 @@ public abstract class CacheBasedWebSession implements WebSession {
return val != null ? val.getExternalId() : null;
}
@Override
public Account.Id getAccountId() {
return val != null ? val.getAccountId() : null;
}
@Override
public CurrentUser getUser() {
if (user == null) {

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.httpd;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Account.Id;
import com.google.gerrit.reviewdb.client.AccountExternalId;
import com.google.gerrit.server.AccessPath;
import com.google.gerrit.server.CurrentUser;
@@ -35,4 +36,5 @@ public interface WebSession {
void logout();
String getSessionId();
Id getAccountId();
}