@@ -158,6 +158,7 @@ public class Client implements AutoCloseable {
158
158
final ExecutorService dispatchingExecutorService ;
159
159
final TuneState tuneState ;
160
160
final AtomicBoolean closing = new AtomicBoolean (false );
161
+ final AtomicBoolean shuttingDownDispatching = new AtomicBoolean (false );
161
162
final ChunkChecksum chunkChecksum ;
162
163
final MetricsCollector metricsCollector ;
163
164
final CompressionCodecFactory compressionCodecFactory ;
@@ -354,6 +355,7 @@ public void initChannel(SocketChannel ch) {
354
355
() -> {
355
356
if (dispatchingExecutorServiceFactory == null ) {
356
357
List <Runnable > outstandingTasks = this .dispatchingExecutorService .shutdownNow ();
358
+ this .shuttingDownDispatching .set (true );
357
359
for (Runnable outstandingTask : outstandingTasks ) {
358
360
try {
359
361
outstandingTask .run ();
@@ -2778,7 +2780,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
2778
2780
}
2779
2781
} else {
2780
2782
FrameHandler frameHandler = ServerFrameHandler .lookup (commandId , version , m );
2781
- task = new FrameHandlerTask (frameHandler , Client .this , frameSize , ctx , m , closing );
2783
+ task =
2784
+ new FrameHandlerTask (
2785
+ frameHandler , Client .this , frameSize , ctx , m , shuttingDownDispatching );
2782
2786
}
2783
2787
2784
2788
if (task != null ) {
@@ -2854,26 +2858,26 @@ private static class FrameHandlerTask implements Runnable {
2854
2858
private final int frameSize ;
2855
2859
private final ChannelHandlerContext ctx ;
2856
2860
private final ByteBuf message ;
2857
- private final AtomicBoolean closing ;
2861
+ private final AtomicBoolean shouldRelease ;
2858
2862
2859
2863
private FrameHandlerTask (
2860
2864
FrameHandler frameHandler ,
2861
2865
Client client ,
2862
2866
int frameSize ,
2863
2867
ChannelHandlerContext ctx ,
2864
2868
ByteBuf message ,
2865
- AtomicBoolean closing ) {
2869
+ AtomicBoolean shouldRelease ) {
2866
2870
this .frameHandler = frameHandler ;
2867
2871
this .client = client ;
2868
2872
this .frameSize = frameSize ;
2869
2873
this .ctx = ctx ;
2870
2874
this .message = message ;
2871
- this .closing = closing ;
2875
+ this .shouldRelease = shouldRelease ;
2872
2876
}
2873
2877
2874
2878
@ Override
2875
2879
public void run () {
2876
- if (this .closing .get ()) {
2880
+ if (this .shouldRelease .get ()) {
2877
2881
try {
2878
2882
this .message .release ();
2879
2883
} catch (Exception e ) {
0 commit comments