Source:
private synchronized StreamObserver<QueryProviderOutbound> getSubscriberObserver(String context) { if (outboundStreamObserver != null) { return outboundStreamObserver; } AtomicReference<StreamObserver<QueryProviderInbound>> inboundStreamRef = new AtomicReference<>(); StreamObserver<QueryProviderInbound> queryProviderInboundStreamObserver = new UpstreamAwareStreamObserver<QueryProviderInbound>() { @Override public void onNext(QueryProviderInbound inboundRequest) { RequestCase requestCase = inboundRequest.getRequestCase(); Collection<BiConsumer<QueryProviderInbound, StreamObserver<QueryProviderOutbound>>> defaultHandlers = Collections .singleton((qpi, stream) -> sendUnsuccessfulInstructionResult(inboundRequest.getInstructionId(), unsupportedInstruction(), stream)); queryHandlers.getOrDefault(configuration.getContext(), requestCase, defaultHandlers) .forEach(consumer -> consumer.accept(inboundRequest, (StreamObserver<QueryProviderOutbound>) getRequestStream())); } @SuppressWarnings("Duplicates") @Override public void onError(Throwable ex) { logger.warn("Query Inbound Stream closed with error", ex); outboundStreamObserver = null; } @Override public void onCompleted() { logger.info("Received completed from server."); outboundStreamObserver = null; } }; ResubscribableStreamObserver<QueryProviderInbound> resubscribableStreamObserver = new ResubscribableStreamObserver<>(queryProviderInboundStreamObserver, t -> resubscribe()); inboundStreamRef.set(resubscribableStreamObserver); StreamObserver<QueryProviderOutbound> streamObserver = axonServerConnectionManager.getQueryStream( context, resubscribableStreamObserver ); logger.info("Creating new query stream subscriber"); outboundStreamObserver = new FlowControllingStreamObserver<>( streamObserver, configuration, flowControl -> QueryProviderOutbound.newBuilder().setFlowControl(flowControl).build(), t -> t.getRequestCase().equals(QueryProviderOutbound.RequestCase.QUERY_RESPONSE) ).sendInitialPermits(); return outboundStreamObserver; }

Target:
private synchronized StreamObserver<QueryProviderOutbound> getSubscriberObserver(String context) { if (outboundStreamObserver != null) { return outboundStreamObserver; } StreamObserver<QueryProviderInbound> queryProviderInboundStreamObserver = new UpstreamAwareStreamObserver<QueryProviderInbound>() { @Override public void onNext(QueryProviderInbound inboundRequest) { RequestCase requestCase = inboundRequest.getRequestCase(); Collection<BiConsumer<QueryProviderInbound, StreamObserver<QueryProviderOutbound>>> defaultHandlers = Collections .singleton((qpi, stream) -> instructionAckSource .sendUnsupportedInstruction(qpi.getInstructionId(), configuration.getClientId(), stream)); queryHandlers.getOrDefault(configuration.getContext(), requestCase, defaultHandlers) .forEach(consumer -> consumer.accept(inboundRequest, requestStreamFactory.apply(this))); } @SuppressWarnings("Duplicates") @Override public void onError(Throwable ex) { logger.warn("Query Inbound Stream closed with error", ex); outboundStreamObserver = null; } @Override public void onCompleted() { logger.info("Received completed from server."); outboundStreamObserver = null; } }; ResubscribableStreamObserver<QueryProviderInbound> resubscribableStreamObserver = new ResubscribableStreamObserver<>(queryProviderInboundStreamObserver, t -> resubscribe()); StreamObserver<QueryProviderOutbound> streamObserver = axonServerConnectionManager.getQueryStream( context, resubscribableStreamObserver ); logger.info("Creating new query stream subscriber"); outboundStreamObserver = new FlowControllingStreamObserver<>( streamObserver, configuration, flowControl -> QueryProviderOutbound.newBuilder().setFlowControl(flowControl).build(), t -> t.getRequestCase().equals(QueryProviderOutbound.RequestCase.QUERY_RESPONSE) ).sendInitialPermits(); return outboundStreamObserver; }