Camel Split component fails with java.nio.charset.MalformedInputException

Solution Verified - Updated -

Issue

To avoid OOME with convertBodyTo(), we want to use split().tokenize().streaming(). However, it does not work due to java.nio.charset.MalformedInputException.

Caused by: java.nio.charset.MalformedInputException: Input length = 1
    at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    at java.io.Reader.read(Reader.java:100)
    at org.apache.camel.util.Scanner.readMore(Scanner.java:154)
    at org.apache.camel.util.Scanner.hasNext(Scanner.java:112)
    at org.apache.camel.util.GroupTokenIterator.hasNext(GroupTokenIterator.java:119)
    at org.apache.camel.processor.Splitter$SplitterIterable$1.hasNext(Splitter.java:188)
    ... 79 common frames omitted

camel route

        from("file:///sample/input"
                + "?fileName=sampleLargeFile"
                + "&charset=MS932&"
                + "noop=true&idempotent=false")
        .removeProperty(Exchange.CHARSET_NAME)
        .choice()
            .when(body().isNotNull())
                .split().tokenize("\n", 5000).streaming()
                    .split(simple("${body}"))
                        .log("${body}")
                    .end()
                .end()
        .end();

Environment

  • Red Hat Fuse
    • 7.8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content