Skip to content

Commit

Permalink
netty: use server factory consistently; use IllegalArgumentException
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Nov 12, 2020
1 parent ef112c9 commit 01b9919
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
Expand Up @@ -31,7 +31,7 @@ private InternalNettyServerCredentials() {}

/** Creates a {@link ServerCredentials} that will use the provided {@code negotiator}. */
public static ServerCredentials create(InternalProtocolNegotiator.ProtocolNegotiator negotiator) {
return NettyServerCredentials.create(negotiator);
return NettyServerCredentials.create(ProtocolNegotiators.fixedServerFactory(negotiator));
}

/**
Expand Down
4 changes: 0 additions & 4 deletions netty/src/main/java/io/grpc/netty/NettyServerCredentials.java
Expand Up @@ -21,10 +21,6 @@

/** A credential with full control over the security handshake. */
final class NettyServerCredentials extends ServerCredentials {
public static ServerCredentials create(ProtocolNegotiator negotiator) {
return create(ProtocolNegotiators.fixedServerFactory(negotiator));
}

public static ServerCredentials create(ProtocolNegotiator.ServerFactory negotiator) {
return new NettyServerCredentials(negotiator);
}
Expand Down
Expand Up @@ -34,6 +34,6 @@ public static ServerCredentials create(SslContext sslContext) {
Preconditions.checkArgument(sslContext.isServer(),
"Client SSL context can not be used for server");
GrpcSslContexts.ensureAlpnAndH2Enabled(sslContext.applicationProtocolNegotiator());
return NettyServerCredentials.create(ProtocolNegotiators.serverTls(sslContext));
return NettyServerCredentials.create(ProtocolNegotiators.serverTlsFactory(sslContext));
}
}
2 changes: 1 addition & 1 deletion netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
Expand Up @@ -192,7 +192,7 @@ public static FromServerCredentialsResult from(ServerCredentials creds) {
try {
sslContext = builder.build();
} catch (SSLException ex) {
throw new RuntimeException(
throw new IllegalArgumentException(
"Unexpected error converting ServerCredentials to Netty SslContext", ex);
}
return FromServerCredentialsResult.negotiator(serverTlsFactory(sslContext));
Expand Down

0 comments on commit 01b9919

Please sign in to comment.