Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

XML-Inputstream should not be converted to String and back to InputStream #86

@rscadrde

Description

@rscadrde

The commit
956bedf
made correct inputstream parsing fail:

We are using mule-module-apikit 1.7.3 and a mule server 3.7.3 running with file.encoding=Cp1252.

When posting an xml

<?xml version='1.0' encoding='UTF-8'?>
<ns0:BatteryType xmlns:ns0="http://www.ptc.com/flexplm/cunda/batterytype">
  <ns0:Id>18</ns0:Id>
  <ns0:Text>Hörgerätbatterie</ns0:Text>
</ns0:BatteryType>

message to the api kit router it fails validating the schema with:

[Fatal Error] :4:13: Invalid byte 2 of 4-byte UTF-8 sequence.
because RestXmlSchemaValidator first makes a String out of the inputstream with UTF-8 encoding:

input = IOUtils.toString((InputStream) input, muleEvent.getMessage().getEncoding());
and 7 lines later parses it with

data = loadDocument(IOUtils.toInputStream((String) input));
which uses Charset.defaultCharset() = "Cp1252"

and so the xml parser fails as the "ä" is now Cp1252 encoded but xml-header tells him UTF-8'.

Before the commit

https://github.com/mulesoft/apikit/commit/956bedf243dbfd306cfefa6f4b33712953e32455
the code of RestJsonSchemaValidator.java was correct to directly let the DocumentBuilder parse the inputstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions