Skip to content

Commit 12586b1

Browse files
committed
Remove unnecessary local variable in getAuthMechanism.
1 parent 38b0a3a commit 12586b1

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

s2a/src/main/java/io/grpc/s2a/handshaker/GetAuthenticationMechanisms.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,23 @@ final class GetAuthenticationMechanisms {
3333
* @return an {@link AuthenticationMechanism} for the given local identity.
3434
*/
3535
static Optional<AuthenticationMechanism> getAuthMechanism(Optional<S2AIdentity> localIdentity) {
36-
Optional<AuthenticationMechanism> authMechanism = Optional.empty();
3736
if (!TOKEN_MANAGER.isPresent()) {
3837
return Optional.empty();
3938
}
4039
AccessTokenManager manager = TOKEN_MANAGER.get();
4140
// If no identity is provided, fetch the default access token and DO NOT attach an identity
4241
// to the request.
4342
if (!localIdentity.isPresent()) {
44-
authMechanism =
45-
Optional.of(
43+
return Optional.of(
4644
AuthenticationMechanism.newBuilder().setToken(manager.getDefaultToken()).build());
4745
} else {
4846
// Fetch an access token for the provided identity.
49-
authMechanism =
50-
Optional.of(
47+
return Optional.of(
5148
AuthenticationMechanism.newBuilder()
5249
.setIdentity(localIdentity.get().getIdentity())
5350
.setToken(manager.getToken(localIdentity.get()))
5451
.build());
5552
}
56-
return authMechanism;
5753
}
5854

5955
private GetAuthenticationMechanisms() {}

0 commit comments

Comments
 (0)