This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0f04960fdf126c0a602e97d293ae109690cae974 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Wed Jan 4 17:55:46 2023 +0100 (chores) camel-mllp: avoid risky unboxing --- .../apache/camel/component/mllp/MllpEndpoint.java | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java index ee5f19e8386..55696667a36 100644 --- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java +++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java @@ -307,16 +307,22 @@ public class MllpEndpoint extends DefaultEndpoint { final String logMessageFormat = "Exchange property {} = {} - {} connection"; boolean answer = true; - if (exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_BEFORE_SEND, boolean.class)) { + final boolean resetBeforeSend + = exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_BEFORE_SEND, false, boolean.class); + if (resetBeforeSend) { log.warn(logMessageFormat, MllpConstants.MLLP_RESET_CONNECTION_BEFORE_SEND, exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_BEFORE_SEND), "resetting"); doConnectionClose(socket, true, null); answer = false; - } else if (exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND, boolean.class)) { - log.warn(logMessageFormat, MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND, - exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND), "closing"); - doConnectionClose(socket, false, null); - answer = false; + } else { + final boolean closeBeforeSend + = exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND, false, boolean.class); + if (closeBeforeSend) { + log.warn(logMessageFormat, MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND, + exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_BEFORE_SEND), "closing"); + doConnectionClose(socket, false, null); + answer = false; + } } return answer; @@ -326,16 +332,22 @@ public class MllpEndpoint extends DefaultEndpoint { final String logMessageFormat = "Exchange property {} = {} - {} connection"; boolean answer = true; - if (exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_AFTER_SEND, boolean.class)) { + final boolean resetAfterSend + = exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_AFTER_SEND, false, boolean.class); + if (resetAfterSend) { log.warn(logMessageFormat, MllpConstants.MLLP_RESET_CONNECTION_AFTER_SEND, exchange.getProperty(MllpConstants.MLLP_RESET_CONNECTION_AFTER_SEND), "resetting"); doConnectionClose(socket, true, log); answer = false; - } else if (exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND, boolean.class)) { - log.warn(logMessageFormat, MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND, - exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND), "closing"); - doConnectionClose(socket, false, log); - answer = false; + } else { + final boolean closeAfterSend + = exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND, false, boolean.class); + if (closeAfterSend) { + log.warn(logMessageFormat, MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND, + exchange.getProperty(MllpConstants.MLLP_CLOSE_CONNECTION_AFTER_SEND), "closing"); + doConnectionClose(socket, false, log); + answer = false; + } } return answer;
