mirror of https://github.com/grpc/grpc-java.git
Refactor so that calculation happens in constructor rather than checking for a null value to lazily initialize it. (#10101)
Fixes b/277276312
This commit is contained in:
parent
c4c9939887
commit
e89e0ccfee
|
|
@ -63,7 +63,7 @@ final class GoogleAuthLibraryCallCredentials extends io.grpc.CallCredentials
|
||||||
private Metadata lastHeaders;
|
private Metadata lastHeaders;
|
||||||
private Map<String, List<String>> lastMetadata;
|
private Map<String, List<String>> lastMetadata;
|
||||||
|
|
||||||
private Boolean requiresSpecificExecutor;
|
private final boolean requiresSpecificExecutor;
|
||||||
|
|
||||||
public GoogleAuthLibraryCallCredentials(Credentials creds) {
|
public GoogleAuthLibraryCallCredentials(Credentials creds) {
|
||||||
this(creds, jwtHelper);
|
this(creds, jwtHelper);
|
||||||
|
|
@ -85,6 +85,13 @@ final class GoogleAuthLibraryCallCredentials extends io.grpc.CallCredentials
|
||||||
}
|
}
|
||||||
this.requirePrivacy = requirePrivacy;
|
this.requirePrivacy = requirePrivacy;
|
||||||
this.creds = creds;
|
this.creds = creds;
|
||||||
|
|
||||||
|
// Cache the value so we only need to try to load the class once
|
||||||
|
if (APP_ENGINE_CREDENTIALS_CLASS == null) {
|
||||||
|
requiresSpecificExecutor = false;
|
||||||
|
} else {
|
||||||
|
requiresSpecificExecutor = APP_ENGINE_CREDENTIALS_CLASS.isInstance(creds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -377,15 +384,6 @@ final class GoogleAuthLibraryCallCredentials extends io.grpc.CallCredentials
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSpecificExecutorRequired() {
|
public boolean isSpecificExecutorRequired() {
|
||||||
// Cache the value so we only need to try to load the class once
|
|
||||||
if (requiresSpecificExecutor == null) {
|
|
||||||
if (APP_ENGINE_CREDENTIALS_CLASS == null) {
|
|
||||||
requiresSpecificExecutor = Boolean.FALSE;
|
|
||||||
} else {
|
|
||||||
requiresSpecificExecutor = APP_ENGINE_CREDENTIALS_CLASS.isInstance(creds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return requiresSpecificExecutor;
|
return requiresSpecificExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue