|
|
|
@ -154,10 +154,30 @@ public class EdgeGrpcClient implements EdgeRpcClient { |
|
|
|
if (!onError) { |
|
|
|
try { |
|
|
|
inputStream.onCompleted(); |
|
|
|
} catch (Exception ignored) {} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("Exception during onCompleted", e); |
|
|
|
} |
|
|
|
} |
|
|
|
if (channel != null) { |
|
|
|
channel.shutdown().awaitTermination(timeoutSecs, TimeUnit.SECONDS); |
|
|
|
channel.shutdown(); |
|
|
|
int attempt = 0; |
|
|
|
do { |
|
|
|
try { |
|
|
|
channel.awaitTermination(timeoutSecs, TimeUnit.SECONDS); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("Channel await termination was interrupted", e); |
|
|
|
} |
|
|
|
if (attempt > 5) { |
|
|
|
log.warn("We had reached maximum of termination attempts. Force closing channel"); |
|
|
|
try { |
|
|
|
channel.shutdownNow(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("Exception during shutdownNow", e); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
attempt++; |
|
|
|
} while (!channel.isTerminated()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|