File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
driver-core/src/main/com/mongodb/connection/netty Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 2424import java .util .concurrent .ScheduledFuture ;
2525import java .util .concurrent .TimeUnit ;
2626
27+ import static com .mongodb .assertions .Assertions .isTrue ;
2728import static com .mongodb .assertions .Assertions .isTrueArgument ;
2829
2930/**
@@ -40,14 +41,17 @@ public ReadTimeoutHandler(final long readTimeout) {
4041 }
4142
4243 void scheduleTimeout (final ChannelHandlerContext ctx ) {
43- timeout = ctx .executor ().schedule (new ReadTimeoutTask (ctx ), readTimeout , TimeUnit .MILLISECONDS );
44+ isTrue ("Handler called from the eventLoop" , ctx .channel ().eventLoop ().inEventLoop ());
45+ if (timeout == null ) {
46+ timeout = ctx .executor ().schedule (new ReadTimeoutTask (ctx ), readTimeout , TimeUnit .MILLISECONDS );
47+ }
4448 }
4549
4650 void removeTimeout (final ChannelHandlerContext ctx ) {
47- if ( ctx .channel ().eventLoop ().inEventLoop ()) {
48- if (timeout != null ) {
49- timeout .cancel (false );
50- }
51+ isTrue ( "Handler called from the eventLoop" , ctx .channel ().eventLoop ().inEventLoop ());
52+ if (timeout != null ) {
53+ timeout .cancel (false );
54+ timeout = null ;
5155 }
5256 }
5357
You can’t perform that action at this time.
0 commit comments