Croway commented on PR #25555: URL: https://github.com/apache/camel/pull/25555#issuecomment-5394457624
I am not a big fan of reimplementing _looksLikeXml_ since something similar is already done in **camel-xml-io-util XmlStreamReader** with the methods _getBOMEncoding_ and _getXMLGuessEncoding_ (private at the moment). The current implementation also rejects XML that Xerces auto-detects fine today, e.g. **BOM-less UTF-16BE**, **UTF-32** and **EBCDIC**, those byte patterns are exactly what getXMLGuessEncoding handles. Therefore I'd do one of the following: - expose a small public static probe in _XmlStreamReader_ (e.g. looksLikeXml(byte[] prefix) or guessEncoding(byte[])) and call it from XmlConverter instead of reimplementing it, this fixes the encodings the current check rejects - drop the sniff entirely: catch _SAXParseException_ and rethrow with a friendly message. This also covers the other overloads that still throw the raw "Content is not allowed in prolog" (String, InputStream, toDOMSource…), and lets toDOMDocument(StreamCache) keep streaming instead of loading the whole payload into a byte[] -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
