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 24
24
import java .util .concurrent .ScheduledFuture ;
25
25
import java .util .concurrent .TimeUnit ;
26
26
27
+ import static com .mongodb .assertions .Assertions .isTrue ;
27
28
import static com .mongodb .assertions .Assertions .isTrueArgument ;
28
29
29
30
/**
@@ -40,14 +41,17 @@ public ReadTimeoutHandler(final long readTimeout) {
40
41
}
41
42
42
43
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
+ }
44
48
}
45
49
46
50
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 ;
51
55
}
52
56
}
53
57
You can’t perform that action at this time.
0 commit comments