Fix NodeDescriptorImporterBase.fromString to handle non ascii chars in xml file #120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #119
Arqullian uses this code to parse "arquillian.xml": https://github.com/arquillian/arquillian-core/blob/main/config/impl-base/src/main/java/org/jboss/arquillian/config/impl/extension/ClasspathConfigurationPlaceholderResolver.java
It exports a descriptor to a string, replaces some placeholders and reimports the descriptor from this string.
This fails if "arquillian.xml" contains non-ascii chars (though the xml files defines "UTF-8" encoding).
This pull request adds an override
fromString
toNodeDescriptorImporterBase
. In this method, I create ajava.io.StringReader
, which is passed to the new methodNodeImporter.importAsNode(Reader)
, implemented inXmlDomNodeImporterImpl
. Here, aorg.xml.sax.InputSource
is created using this Reader, and theDocumentBuilder
parses this source.The
NodeDescriptorImporterBase
base classDescriptorImporterBase
still contains the previous implementation offromString
that callsfromStream(new ByteArrayInputStream(string.getBytes()))
. I would have preferred to add afromReader
to the base class too, but this would have meant adding a method to the interfaceorg.jboss.shrinkwrap.descriptor.api.DescriptorImporter
.Things to improve - please give me feedback:
NodeDescriptorImporterBase
: the existingfromStream
and my new methodfromString
contain similar code. The part after the comment "// Create the end-user view" could be extracted to a helper method.XmlDomNodeImporterImpl.importAsNode(Reader)
.I tested it in my sample project and will attach a ut8 "arquillian.xml" and a "windows-1252" file (both containing umlauts in a comment) to #119. Both files did not show the failure from the initial bugreport.