You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Freeman Yue Fang (Jira)" <ji...@apache.org> on 2021/11/04 20:02:00 UTC

[jira] [Comment Edited] (CAMEL-17128) MLLP charset is no longer overrridable from the HL7 message MSH 18

    [ https://issues.apache.org/jira/browse/CAMEL-17128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17438909#comment-17438909 ] 

Freeman Yue Fang edited comment on CAMEL-17128 at 11/4/21, 8:01 PM:
--------------------------------------------------------------------

If we change MllpCharsetHelper a bit to check charset firstly from the MSH 18 of the HL7 message like below, this can fix the mllp test case in camel-quarkus.

So the logic is 
1. check charset from MSH 18 of the HL7 message 
2. if not find check the charset set in the exchange
3. if not find return the default charset.

If this change(it won't break tests in camel-mllp component) is OK I will send a PR

{code}
git diff .
diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
index 52e15388eea3..b5b4faca4265 100644
--- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
+++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
@@ -43,16 +43,6 @@ public final class MllpCharsetHelper {
     }
 
     public static Charset getCharset(Exchange exchange, byte[] hl7Bytes, Hl7Util hl7Util, Charset defaultCharset) {
-        String exchangeCharsetName = ExchangeHelper.getCharsetName(exchange, false);
-        if (exchangeCharsetName != null && !exchangeCharsetName.isEmpty()) {
-            try {
-                if (Charset.isSupported(exchangeCharsetName)) {
-                    return Charset.forName(exchangeCharsetName);
-                }
-            } catch (Exception charsetEx) {
-                // ignore
-            }
-        }
 
         String msh18 = hl7Util.findMsh18(hl7Bytes, defaultCharset);
         if (msh18 != null && !msh18.isEmpty()) {
@@ -68,6 +58,16 @@ public final class MllpCharsetHelper {
             }
         }
 
+        String exchangeCharsetName = ExchangeHelper.getCharsetName(exchange, false);
+        if (exchangeCharsetName != null && !exchangeCharsetName.isEmpty()) {
+            try {
+                if (Charset.isSupported(exchangeCharsetName)) {
+                    return Charset.forName(exchangeCharsetName);
+                }
+            } catch (Exception charsetEx) {
+                // ignore
+            }
+        }
         return defaultCharset;
     }
{code}


was (Author: ffang):
If we change MllpCharsetHelper a bit to check charset firstly from the MSH 18 of the HL7 message like below, this can fix the mllp test case in camel-quarkus.

So the logic is 
1. check charset from MSH 18 of the HL7 message 
2. if not find check the charset set in the exchange
3. if not find return the default charset.

If this change is OK I will send a PR

{code}
git diff .
diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
index 52e15388eea3..b5b4faca4265 100644
--- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
+++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpCharsetHelper.java
@@ -43,16 +43,6 @@ public final class MllpCharsetHelper {
     }
 
     public static Charset getCharset(Exchange exchange, byte[] hl7Bytes, Hl7Util hl7Util, Charset defaultCharset) {
-        String exchangeCharsetName = ExchangeHelper.getCharsetName(exchange, false);
-        if (exchangeCharsetName != null && !exchangeCharsetName.isEmpty()) {
-            try {
-                if (Charset.isSupported(exchangeCharsetName)) {
-                    return Charset.forName(exchangeCharsetName);
-                }
-            } catch (Exception charsetEx) {
-                // ignore
-            }
-        }
 
         String msh18 = hl7Util.findMsh18(hl7Bytes, defaultCharset);
         if (msh18 != null && !msh18.isEmpty()) {
@@ -68,6 +58,16 @@ public final class MllpCharsetHelper {
             }
         }
 
+        String exchangeCharsetName = ExchangeHelper.getCharsetName(exchange, false);
+        if (exchangeCharsetName != null && !exchangeCharsetName.isEmpty()) {
+            try {
+                if (Charset.isSupported(exchangeCharsetName)) {
+                    return Charset.forName(exchangeCharsetName);
+                }
+            } catch (Exception charsetEx) {
+                // ignore
+            }
+        }
         return defaultCharset;
     }
{code}

> MLLP charset is no longer overrridable from the HL7 message MSH 18
> ------------------------------------------------------------------
>
>                 Key: CAMEL-17128
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17128
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-mllp
>    Affects Versions: 3.13.0
>            Reporter: James Netherton
>            Priority: Minor
>
> Seems that in the latest 3.13 SNAPSHOT it is no longer possible for the charset to be set from the HL7 message sent to the MLLP consumer. The default charset does not appear to be overridable as it's always setting the charset exchange header.
> See also:
> https://github.com/apache/camel-quarkus/issues/3225
> Test case in camel-quarkus:
> https://github.com/apache/camel-quarkus/blob/main/integration-tests/mllp/src/test/java/org/apache/camel/quarkus/component/mllp/it/MllpTest.java#L57-L78



--
This message was sent by Atlassian Jira
(v8.3.4#803005)