Skip to content

Commit 85d4681

Browse files
committed
Use constant and cancel shutdown task
Fixes #194
1 parent 427d502 commit 85d4681

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/com/rabbitmq/client/impl/ChannelManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ChannelManager {
5252
private ExecutorService shutdownExecutor;
5353
private final ThreadFactory threadFactory;
5454

55-
private int channelShutdownTimeout = (int) ((ConnectionFactory.DEFAULT_HEARTBEAT * 1.05) * 1000);
55+
private int channelShutdownTimeout = (int) ((ConnectionFactory.DEFAULT_HEARTBEAT * AMQConnection.CHANNEL_SHUTDOWN_TIMEOUT_MULTIPLIER) * 1000);
5656

5757
protected final MetricsCollector metricsCollector;
5858

src/main/java/com/rabbitmq/client/impl/SocketFrameHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,18 @@ public Void call() throws Exception {
175175
return null;
176176
}
177177
};
178+
Future<Void> flushTask = null;
178179
try {
179180
if(this._shutdownExecutor == null) {
180181
flushCallable.call();
181182
} else {
182-
Future<Void> flushTask = this._shutdownExecutor.submit(flushCallable);
183+
flushTask = this._shutdownExecutor.submit(flushCallable);
183184
flushTask.get(SOCKET_CLOSING_TIMEOUT, TimeUnit.SECONDS);
184185
}
185186
} catch(Exception e) {
186-
187+
if(flushTask != null) {
188+
flushTask.cancel(true);
189+
}
187190
}
188191
try { _socket.close(); } catch (Exception _e) {}
189192
}

0 commit comments

Comments
 (0)