Declare channel outside try/catch

No StatusRuntimeException can be thrown from this code, so it is not
necessary to include in the try block.
This commit is contained in:
Chris Beams 2020-04-26 19:38:06 +02:00
parent 0a2aac00d3
commit b7fda8de5e
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73

View File

@ -115,17 +115,17 @@ public class CliMain {
exit(EXIT_FAILURE);
}
try {
var channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
channel.shutdown().awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
ex.printStackTrace(err);
exit(EXIT_FAILURE);
}
}));
var channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
channel.shutdown().awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
ex.printStackTrace(err);
exit(EXIT_FAILURE);
}
}));
try {
var credentials = new PasswordCallCredentials(password);
switch (method) {