Skip to content

Commit

Permalink
Null check result of HttpServerBuilder supplier (#2317)
Browse files Browse the repository at this point in the history
Null check result of `HttpServerBuilder` supplier
Motivation:
`DefaultGrpcServerBuilder` invokes a provided Supplier without checking
the result for null. A `NullPointerException` will occur, but will not
include context about what was null.
Modifications:
Add `Objects.requireNonNull` check when invoking `Supplier`
Result:
Better diagnostic for failed Supplier.
  • Loading branch information
bondolo authored Aug 10, 2022
1 parent d46dbd6 commit 17fbb91
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ final class DefaultGrpcServerBuilder implements GrpcServerBuilder, ServerBinder

// Do not use this ctor directly, GrpcServers is the entry point for creating a new builder.
DefaultGrpcServerBuilder(final Supplier<HttpServerBuilder> httpServerBuilderSupplier) {
this.httpServerBuilderSupplier = () -> httpServerBuilderSupplier.get()
.protocols(h2Default()).allowDropRequestTrailers(true);
this.httpServerBuilderSupplier = () ->
requireNonNull(httpServerBuilderSupplier.get(), "Supplier<HttpServerBuilder> result was null")
.protocols(h2Default()).allowDropRequestTrailers(true);
}

@Override
Expand Down

0 comments on commit 17fbb91

Please sign in to comment.