From 8a024c7c932240754e4a91a053381b12d0265643 Mon Sep 17 00:00:00 2001 From: malakaganga Date: Mon, 15 Jul 2024 15:45:56 +0530 Subject: [PATCH] Clear buffered is and json stream in a Build failure Fixes: https://github.com/wso2/micro-integrator/issues/3404 --- .../apache/synapse/transport/passthru/util/RelayUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayUtils.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayUtils.java index c271ae0ea5..384c37b41e 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayUtils.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/util/RelayUtils.java @@ -40,6 +40,7 @@ import org.apache.http.nio.NHttpServerConnection; import org.apache.http.nio.reactor.IOSession; import org.apache.synapse.commons.CorrelationConstants; +import org.apache.synapse.commons.json.JsonUtil; import org.apache.synapse.transport.http.conn.LoggingNHttpServerConnection; import org.apache.synapse.transport.nhttp.NhttpConstants; import org.apache.synapse.transport.passthru.PassThroughConstants; @@ -219,8 +220,12 @@ public static void buildMessage(MessageContext messageContext, boolean earlyBuil } } } catch (Exception e) { + //removing JSONstream from the message Context since it is outdated. + JsonUtil.removeJsonPayload(messageContext); //Clearing the buffer when there is an exception occurred. discardRequestMessage(messageContext); + //Clearing the buffered input stream when there is an build exception occurred. + messageContext.setProperty(PassThroughConstants.BUFFERED_INPUT_STREAM, null); messageContext.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE); handleException("Error while building Passthrough stream", e); }