grpc-ecosystem / grpc-ecosystem/grpc-spring

Maybe resolve a supplier in the DynamicSecurityHeaderCallCredentials in an executor to avoid blocking the thread

Open
#958 2 comments 0 reactions 1 assignee Claimed by @ST-DDT View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.