Skip to content

Commit

Permalink
Cache the result of GitLab's current user
Browse files Browse the repository at this point in the history
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Sep 4, 2020
1 parent 7a18b0b commit 07930a4
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -40,6 +40,8 @@ public class GitLabHost implements Forge {
private final RestRequest request;
private final Logger log = Logger.getLogger("org.openjdk.skara.forge.gitlab");

private HostUser cachedCurrentUser = null;

GitLabHost(String name, URI uri, Credential pat) {
this.name = name;
this.uri = uri;
Expand Down Expand Up @@ -164,8 +166,12 @@ public Optional<HostUser> user(String username) {

@Override
public HostUser currentUser() {
if (cachedCurrentUser != null) {
return cachedCurrentUser;
}
var details = request.get("user").execute().asObject();
return parseAuthorObject(details);
cachedCurrentUser = parseAuthorObject(details);
return cachedCurrentUser;
}

@Override
Expand Down

1 comment on commit 07930a4

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 07930a4 Sep 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.