Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72529

On z/OS mismatch between generated settings files’ encoding and maven’s encoding recognition

XMLWordPrintable

    • 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

      1. 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).
      2. 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

      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)
      

            bguerin Benoit
            lne Lutz Neugebauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: