Source:
private Object doSendAndReceive(Object object, boolean shouldConvert) { initializeIfNecessary(); Assert.notNull(object, "request must not be null"); MessageChannel channel = getRequestChannel(); if (channel == null) { throw new MessagingException("No request channel available. Cannot send request message."); } registerReplyMessageCorrelatorIfNecessary(); Object reply; Message<?> requestMessage = null; SampleFacade sample = null; try { if (this.metricsCaptor != null) { sample = this.metricsCaptor.start(); } if (shouldConvert) { reply = this.messagingTemplate.convertSendAndReceive(channel, object, Object.class, this.historyWritingPostProcessor); } else { requestMessage = (object instanceof Message<?>) ? (Message<?>) object : this.requestMapper.toMessage(object); Assert.state(requestMessage != null, () -> "request mapper resulted in no message for " + object); requestMessage = this.historyWritingPostProcessor.postProcessMessage(requestMessage); reply = this.messagingTemplate.sendAndReceive(channel, requestMessage); } if (reply == null && this.errorOnTimeout) { throwMessageTimeoutException(object, "No reply received within timeout"); } if (sample != null) { sample.stop(sendTimer()); } } catch (Throwable ex) { if (logger.isDebugEnabled()) { logger.debug("failure occurred in gateway sendAndReceive: " + ex.getMessage()); } reply = ex; if (sample != null) { sample.stop(buildSendTimer(false, ex.getClass().getSimpleName())); } } if (reply instanceof Throwable || reply instanceof ErrorMessage) { Throwable error = reply instanceof ErrorMessage ? ((ErrorMessage) reply).getPayload() : (Throwable) reply; try { return handleSendAndReceiveError(object, requestMessage, error, shouldConvert); } catch (MessagingException me) { if (me.getCause() instanceof Error) { throw (Error) me.getCause(); } } } return reply; }

Target:
private Object doSendAndReceive(Object object, boolean shouldConvert) { initializeIfNecessary(); Assert.notNull(object, "request must not be null"); MessageChannel channel = getRequestChannel(); if (channel == null) { throw new MessagingException("No request channel available. Cannot send request message."); } registerReplyMessageCorrelatorIfNecessary(); Object reply; Message<?> requestMessage = null; SampleFacade sample = null; try { if (this.metricsCaptor != null) { sample = this.metricsCaptor.start(); } if (shouldConvert) { reply = this.messagingTemplate.convertSendAndReceive(channel, object, Object.class, this.historyWritingPostProcessor); } else { requestMessage = (object instanceof Message<?>) ? (Message<?>) object : this.requestMapper.toMessage(object); Assert.state(requestMessage != null, () -> "request mapper resulted in no message for " + object); requestMessage = this.historyWritingPostProcessor.postProcessMessage(requestMessage); reply = this.messagingTemplate.sendAndReceive(channel, requestMessage); } if (reply == null && this.errorOnTimeout) { throwMessageTimeoutException(object, "No reply received within timeout"); } if (sample != null) { sample.stop(sendTimer()); } } catch (Throwable ex) { if (logger.isDebugEnabled()) { logger.debug("failure occurred in gateway sendAndReceive: " + ex.getMessage()); } reply = ex; if (sample != null) { sample.stop(buildSendTimer(false, ex.getClass().getSimpleName())); } } if (reply instanceof Throwable || reply instanceof ErrorMessage) { Throwable error = reply instanceof ErrorMessage ? ((ErrorMessage) reply).getPayload() : (Throwable) reply; return handleSendAndReceiveError(object, requestMessage, error, shouldConvert); } return reply; }