grpc-ecosystem / grpc-ecosystem/grpc-spring
Maybe resolve a supplier in the DynamicSecurityHeaderCallCredentials in an executor to avoid blocking the thread
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
CallCredentials documentation suggests using asynchronous way of setting headers in case there is a blocking function in the code (e.g. a network call).
I would change [this](https://github.com/yidongnan/grpc-spring-boot-starter/blob/9495d5e1f825ad384e96917bdb3a30b09373bd57/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/security/CallCredentialsHelper.java#L341-L345)
```java
@Override
public void applyRequestMetadata(final RequestInfo requestInfo, final Executor appExecutor,
final MetadataApplier applier) {
applier.apply(this.extraHeadersSupplier.get());
}
```
To something like in [this example](https://github.com/grpc/grpc-java/blob/master/examples/example-jwt-auth/src/main/java/io/grpc/examples/jwtauth/JwtCredential.java#L39-L62)
```java
@Override
public void applyRequestMetadata(final RequestInfo requestInfo, final Executor appExecutor,
final MetadataApplier applier) {
executor.execute(new Runnable() {
@Override
public void run() {
try {
applier.apply(this.extraHeadersSupplier.get());
} catch (Throwable t) {
applier.fail(Status.UNAUTHENTICATED.withCause(e));
}
}
});
}
```
Contributor guide
Assessment
This issue has not been assessed yet.