LfsAuthUserProvider: Refactor to avoid name hiding
Change-Id: I910c9061cf38aedcc606a899409c60c74d1fb9e2
diff --git a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsAuthUserProvider.java b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsAuthUserProvider.java
index fcd4736..cc19dd3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsAuthUserProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsAuthUserProvider.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.lfs.auth;
+import static com.google.common.base.MoreObjects.firstNonNull;
import static com.googlesource.gerrit.plugins.lfs.auth.LfsSshRequestAuthorizer.SSH_AUTH_PREFIX;
import com.google.common.base.Strings;
@@ -30,7 +31,7 @@
@Singleton
public class LfsAuthUserProvider {
private final Provider<AnonymousUser> anonymous;
- private final Provider<CurrentUser> user;
+ private final Provider<CurrentUser> currentUser;
private final LfsSshRequestAuthorizer sshAuth;
private final AccountCache accounts;
private final IdentifiedUser.GenericFactory userFactory;
@@ -38,12 +39,12 @@
@Inject
LfsAuthUserProvider(
Provider<AnonymousUser> anonymous,
- Provider<CurrentUser> user,
+ Provider<CurrentUser> currentUser,
LfsSshRequestAuthorizer sshAuth,
AccountCache accounts,
IdentifiedUser.GenericFactory userFactory) {
this.anonymous = anonymous;
- this.user = user;
+ this.currentUser = currentUser;
this.sshAuth = sshAuth;
this.accounts = accounts;
this.userFactory = userFactory;
@@ -61,7 +62,6 @@
}
}
}
- CurrentUser currentUser = user.get();
- return currentUser != null ? currentUser : anonymous.get();
+ return firstNonNull(currentUser.get(), anonymous.get());
}
}