[
https://issues.apache.org/jira/browse/CAMEL-18685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18151692#comment-18151692
]
Claus Ibsen commented on CAMEL-18685:
-------------------------------------
PR: https://github.com/apache/camel/pull/30886
Based on the closed PR https://github.com/apache/camel/pull/24000 by rpamu
(credited as co-author). The file component gets the option charsetErrorAction
(REPORT, the default and today's behaviour, REPLACE or IGNORE) for malformed
input and unmappable characters, when a file is read as text and when it is
written with the charset option. It does not apply together with preMove yet,
as the body is then a java.io.File; that is documented.
_Claude Code on behalf of davsclaus_
> camel-file: charset conversions causing UnmappableCharacterException
> --------------------------------------------------------------------
>
> Key: CAMEL-18685
> URL: https://issues.apache.org/jira/browse/CAMEL-18685
> Project: Camel
> Issue Type: Improvement
> Components: camel-file
> Reporter: Otavio Rodolfo Piske
> Assignee: Claus Ibsen
> Priority: Minor
> Labels: help-wanted
> Fix For: 4.24.0
>
>
> In the file component, reading a file that contains an unmappable character
> causes the component to throw UnmappableCharacterException.
>
> This happens because, by default, the behavior for handling unmapped
> characters in the [Charset class is to report
> them|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/charset/CharsetDecoder.html#decode(java.nio.ByteBuffer)].
>
>
> Ideally, we should allow configuring the behavior so that it can either be
> replaced or ignored. For instance, we can try tweaking the code to use
> something like (in FileOperations) to ignore errors:
>
>
> {code:java}
> Charset.forName(charset).newDecoder().onMalformedInput(CodingErrorAction.IGNORE).charset();
> {code}
>
> Ignore is just one of the options. We may also want to try to replace them
> (as Camel did prior to 2.20).
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)