Fix NodeDescriptorImporterBase.fromString to handle non ascii chars in xml file#120
Open
WolfgangHG wants to merge 2 commits intoshrinkwrap:mainfrom
Open
Fix NodeDescriptorImporterBase.fromString to handle non ascii chars in xml file#120WolfgangHG wants to merge 2 commits intoshrinkwrap:mainfrom
WolfgangHG wants to merge 2 commits intoshrinkwrap:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
fromStringtoNodeDescriptorImporterBase. In this method, I create ajava.io.StringReader, which is passed to the new methodNodeImporter.importAsNode(Reader), implemented inXmlDomNodeImporterImpl. Here, aorg.xml.sax.InputSourceis created using this Reader, and theDocumentBuilderparses this source.The
NodeDescriptorImporterBasebase classDescriptorImporterBasestill contains the previous implementation offromStringthat callsfromStream(new ByteArrayInputStream(string.getBytes())). I would have preferred to add afromReaderto 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 existingfromStreamand my new methodfromStringcontain 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.