Skip to content

Commit

Permalink
fix: make TransportChannel autocloseable (#212)
Browse files Browse the repository at this point in the history
* fix: make TransportChannel autocloseable

* fix: review changes
  • Loading branch information
suraj-qlogic committed Sep 8, 2020
1 parent b635585 commit e4853b1
Showing 1 changed file with 13 additions and 10 deletions.
Expand Up @@ -100,16 +100,19 @@ public GrpcLoggingRpc(final LoggingOptions options) throws IOException {
.usePlaintext()
.executor(executor)
.build();
TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel);
clientContext =
ClientContext.newBuilder()
.setCredentials(null)
.setExecutor(executor)
.setTransportChannel(transportChannel)
.setDefaultCallContext(GrpcCallContext.of(managedChannel, CallOptions.DEFAULT))
.setBackgroundResources(
Collections.<BackgroundResource>singletonList(transportChannel))
.build();
try (TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel)) {
clientContext =
ClientContext.newBuilder()
.setCredentials(null)
.setExecutor(executor)
.setTransportChannel(transportChannel)
.setDefaultCallContext(GrpcCallContext.of(managedChannel, CallOptions.DEFAULT))
.setBackgroundResources(
Collections.<BackgroundResource>singletonList(transportChannel))
.build();
} catch (Exception ex) {
throw new IOException(ex);
}
} else {
LoggingSettingsBuilder settingsBuilder =
new LoggingSettingsBuilder(LoggingSettings.newBuilder().build());
Expand Down

0 comments on commit e4853b1

Please sign in to comment.