File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
src/main/java/com/rabbitmq/client/impl/nio Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,19 @@ public NioLoopContext(SocketChannelFrameHandlerFactory socketChannelFrameHandler
5454 }
5555
5656 void initStateIfNecessary () throws IOException {
57- // FIXME this should be synchronized
58- if (this .readSelectorState == null ) {
59- this .readSelectorState = new SelectorHolder (Selector .open ());
60- this .writeSelectorState = new SelectorHolder (Selector .open ());
57+ // This code is supposed to be called only from the SocketChannelFrameHandlerFactory
58+ // and while holding the lock.
59+ // We lock just in case some other code calls this method in the future.
60+ socketChannelFrameHandlerFactory .lock ();
61+ try {
62+ if (this .readSelectorState == null ) {
63+ this .readSelectorState = new SelectorHolder (Selector .open ());
64+ this .writeSelectorState = new SelectorHolder (Selector .open ());
6165
62- startIoLoops ();
66+ startIoLoops ();
67+ }
68+ } finally {
69+ socketChannelFrameHandlerFactory .unlock ();
6370 }
6471 }
6572
You can’t perform that action at this time.
0 commit comments