Source:
private void handlePublishAsynchronously(HttpServletRequest request, HttpServletResponse response, Topic topic, String messageId) throws IOException { final MessageState messageState = new MessageState(); final AsyncContext asyncContext = request.startAsync(); final HttpResponder httpResponder = new HttpResponder(trackers, messageId, response, asyncContext, topic, errorSender, messageState, request.getRemoteHost()); asyncContext.addListener(new TimeoutAsyncListener(httpResponder, messageState)); asyncContext.addListener(new MetricsAsyncListener(hermesMetrics, topic.getName(), topic.getAck())); asyncContext.setTimeout(topic.isReplicationConfirmRequired() ? longAsyncTimeout : defaultAsyncTimeout); new MessageReader(request, chunkSize, topic.getName(), hermesMetrics, messageState, messageContent -> asyncContext.start(() -> { try { Message message = contentTypeEnforcer.enforce(request.getContentType(), new Message(messageId, messageContent, clock.getTime()), topic); messageValidators.check(topic, message.getData()); message = metadataAddingMessageConverter.addMetadata(message, topic, headersPropagator.extract(toHeadersMap(request))); asyncContext.addListener(new BrokerTimeoutAsyncListener(httpResponder, message, topic, messageState, listeners)); messagePublisher.publish(message, topic, messageState, listeners, new AsyncContextExecutionCallback(asyncContext, new MessageStatePublishingCallback(messageState), new HttpPublishingCallback(httpResponder), new MetricsPublishingCallback(hermesMetrics, topic), new BrokerListenersPublishingCallback(listeners))); } catch (InvalidMessageException | ConvertingException | UnsupportedContentTypeException exception) { logger.warn("Error while parsing message for topic {}", topic.getQualifiedName(), exception); httpResponder.badRequest(exception); } catch (CouldNotLoadSchemaException e) { httpResponder.internalError(e, "Could not load schema for published message"); } }), input -> httpResponder.badRequest(input, "Validation error"), throwable -> httpResponder.internalError(throwable, "Error while reading request")); }

Target:
private void handlePublishAsynchronously(HttpServletRequest request, HttpServletResponse response, Topic topic, String messageId) throws IOException { final MessageState messageState = new MessageState(); final AsyncContext asyncContext = request.startAsync(); final HttpResponder httpResponder = new HttpResponder(trackers, messageId, response, asyncContext, topic, errorSender, messageState, request.getRemoteHost()); asyncContext.addListener(new TimeoutAsyncListener(httpResponder, messageState)); asyncContext.addListener(new MetricsAsyncListener(hermesMetrics, topic.getName(), topic.getAck())); asyncContext.setTimeout(topic.isReplicationConfirmRequired() ? longAsyncTimeout : defaultAsyncTimeout); new MessageReader(request, chunkSize, topic.getName(), hermesMetrics, messageState, messageContent -> asyncContext.start(() -> { try { Message message = contentTypeEnforcer.enforce(request.getContentType(), new Message(messageId, messageContent, clock.getTime()), topic); messageValidators.check(topic, message.getData()); message = metadataAddingMessageConverter.addMetadata(message, topic, headersPropagator.extract(toHeadersMap(request))); asyncContext.addListener(new BrokerTimeoutAsyncListener(httpResponder, message, topic, messageState, listeners)); messagePublisher.publish(message, topic, messageState, listeners, new AsyncContextExecutionCallback(asyncContext, new MessageStatePublishingCallback(messageState), new HttpPublishingCallback(httpResponder), new MetricsPublishingCallback(hermesMetrics, topic), new BrokerListenersPublishingCallback(listeners))); } catch (InvalidMessageException | ConvertingException | UnsupportedContentTypeException exception) { httpResponder.badRequest(exception); } catch (CouldNotLoadSchemaException e) { httpResponder.internalError(e, "Could not load schema for published message"); } }), input -> httpResponder.badRequest(input, "Validation error"), throwable -> httpResponder.internalError(throwable, "Error while reading request")); }