-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
-
1381.v08b_63fa_30559
On z/OS the settings file generated by Pipeline Maven Plugin are written in default platform encoding, but maven is unable to read them in that encoding.
General situation
- Writing of settings files by Pipeline Maven Plugin
Pipeline Maven Plugin is writing the settings files it generates in platform default encoding (cf. WithMavenStepExecution2.java#L1149 for settings and WithMavenStepExecution2.java#L1220 for global settings). - Reading of settings files by Maven
To the best of my understanding, Maven itself uses plexus classes to read the settings files, in particular org.apache.maven.settings.io.xpp3.SettingsXpp3Reader which effectively uses org.codehaus.plexus.util.xml.XmlReader. XmlReader class is guessing the encoding of the xml file read by inspecting the first few bytes trying to find some BOM or an XML declaration being encoded in (UTF-16BE, UTF16LE, UTF-8, or CP1047. If it finds an XML prolog it tries to read it and get the encoding attribute provided there and then uses this. If nothing is found that indicates a certain encoding XmlReader defaults to UTF-8.
That’s just a rough description of the guessing algorithm, not necessarily fully correct or complete. Detailed code starts at XmlReader#doRawStream(…).
Concrete situation we have on z/OS
- Our settings file configured in Jenkins has an XML declaration of “<?xml version="1.0" encoding="UTF-8"?>” as it is used on multiple platforms.
- The default encoding on our z/OS is CP1047 and hence Pipeline Maven Plugin writes settings files using that one.
- XmlReader recognizes the first four characters of the XML declaration being CP1047 encoded (cf. https://github.com/codehaus-plexus/plexus-utils/blob/8488ff2200964f47114b9dee5604dc3314a2fe8a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java#L678). It reads the XML declaration finding there ‘encoding="UTF-8"‘ and hence choses UTF-8 for reading the settings file.
The last step fails because it is CP1047 encoded per previous item with following stack trace:
[ERROR] Error executing Maven.
org.apache.maven.settings.building.SettingsBuildingException: 1 problem was encountered while building the effective settings
[FATAL] Non-parseable settings /path-removed/withMaven6eb5fd5b/settings.xml: only whitespace content allowed before start tag and not L (position: START_DOCUMENT seen L... @1:2) @ / path-removed/withMaven6eb5fd5b/settings.xml, line 1, column 2
at org.apache.maven.settings.building.DefaultSettingsBuilder.build (DefaultSettingsBuilder.java:115)
at org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor.process (SettingsXmlConfigurationProcessor.java:131)
at org.apache.maven.cli.MavenCli.configure (MavenCli.java:1084)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:279)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
- links to