void (@NotNull final RequestFuture<? extends BuilderMessageHandler> future, @Nullable CmdlineRemoteProto.Message.ControllerMessage params) { final BuilderMessageHandler wrappedHandler = new DelegatingMessageHandler() { @Override protected BuilderMessageHandler getDelegateHandler() { return future.getMessageHandler(); } @Override public void sessionTerminated(@NotNull UUID sessionId) { try { super.sessionTerminated(sessionId); } finally { future.setDone(); } } }; final UUID sessionId = future.getRequestID(); mySessionDescriptors.put(sessionId, new SessionData(sessionId, wrappedHandler, params)); }