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

GET .../config.xml -> 500 ("Failed to detect encoding") during hpi:run

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • Platform: All, OS: All

      2009-09-22 16:54:51.519:/:WARN: Error while serving
      http://localhost:8080/job/hgtest/config.xml
      ...
      Caused by: java.io.IOException: Failed to detect encoding of
      /space/src/hudson/trunk/plugins/mercurial/./work/jobs/hgtest/config.xml
      at hudson.XmlFile.sniffEncoding(XmlFile.java:264)
      at hudson.XmlFile.readRaw(XmlFile.java:192)
      at hudson.XmlFile.writeRawTo(XmlFile.java:209)
      at hudson.model.Job.doConfigDotXml(Job.java:969)
      ...

      The file starts:

      <?xml version='1.0' encoding='UTF-8'?>
      <project>

      so I'm not sure what's wrong. Hudson 1.323.

      Anyway why is Hudson trying to find the file's encoding, reading it in a Reader,
      then writing it to a Writer from the servlet output which is set to UTF-8?
      Wouldn't it be simpler to just set content type to application/xml with no
      specified encoding and copy the file as a bytestream from disk? Then
      XmlFile.sniffEncoding, .readRaw, .writeRawTo, and .asString could all be deleted.

      XmlFile.read and .marshal also look suspicious. Why are they assuming UTF-8
      encoding and making a Reader? XStream accepts an InputStream, which would be
      easier and I presume safer.

          [JENKINS-4525] GET .../config.xml -> 500 ("Failed to detect encoding") during hpi:run

          Hello Jesse,

          I think this bug is duplicated by JENKINS-5488. Did you get this error when invoking mvn hpi:run as well?

          Regards
          Mirko

          Mirko Friedenhagen added a comment - Hello Jesse, I think this bug is duplicated by JENKINS-5488 . Did you get this error when invoking mvn hpi:run as well? Regards Mirko

          Mirko Friedenhagen added a comment - I dug into the bug, see the comments following http://issues.jenkins-ci.org/browse/JENKINS-5488?focusedCommentId=135784&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_135784

          Jesse Glick added a comment -

          Yes, it must have been during hpi:run. Duplicate issue contains some valuable information from debugging, though my questions about the design of XmlFile may be valid regardless.

          Jesse Glick added a comment - Yes, it must have been during hpi:run. Duplicate issue contains some valuable information from debugging, though my questions about the design of XmlFile may be valid regardless.

          Hello Jesse, your design doubts seem to be the right way to go, quoting http://xstream.codehaus.org/faq.html#XML:

          XStream all HierarchicalStreamDriver implementation respect the encoding since version 1.3, but only if you provide an InputStream.

          Mirko Friedenhagen added a comment - Hello Jesse, your design doubts seem to be the right way to go, quoting http://xstream.codehaus.org/faq.html#XML: XStream all HierarchicalStreamDriver implementation respect the encoding since version 1.3, but only if you provide an InputStream.

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/XmlFile.java
          core/src/main/java/hudson/model/AbstractItem.java
          http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533
          Log:
          [FIXED JENKINS-4525]

          I'd like to believe that the original reason was because earlier
          versions of XStream that we used early on didn't support the methods
          that take InputStream as a parameter.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/XmlFile.java core/src/main/java/hudson/model/AbstractItem.java http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533 Log: [FIXED JENKINS-4525] I'd like to believe that the original reason was because earlier versions of XStream that we used early on didn't support the methods that take InputStream as a parameter.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #923
          [FIXED JENKINS-4525]

          Kohsuke Kawaguchi : 599888fec1de7e64e716c4e2bc9f164f3e11d533
          Files :

          • changelog.html
          • core/src/main/java/hudson/XmlFile.java
          • core/src/main/java/hudson/model/AbstractItem.java

          dogfood added a comment - Integrated in jenkins_main_trunk #923 [FIXED JENKINS-4525] Kohsuke Kawaguchi : 599888fec1de7e64e716c4e2bc9f164f3e11d533 Files : changelog.html core/src/main/java/hudson/XmlFile.java core/src/main/java/hudson/model/AbstractItem.java

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/XmlFile.java
          core/src/main/java/hudson/model/AbstractItem.java
          http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533
          Log:
          [FIXED JENKINS-4525]

          I'd like to believe that the original reason was because earlier
          versions of XStream that we used early on didn't support the methods
          that take InputStream as a parameter.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/XmlFile.java core/src/main/java/hudson/model/AbstractItem.java http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533 Log: [FIXED JENKINS-4525] I'd like to believe that the original reason was because earlier versions of XStream that we used early on didn't support the methods that take InputStream as a parameter.

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/XmlFile.java
          http://jenkins-ci.org/commit/jenkins/d2c9d7346f0b6f1a66ea466602eb5a79b2730931
          Log:
          [FIXED JENKINS-4525] XML encoding sniffing can fail with old JAXP.

          Modified to assume UTF-8 if we fail to find it.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/XmlFile.java http://jenkins-ci.org/commit/jenkins/d2c9d7346f0b6f1a66ea466602eb5a79b2730931 Log: [FIXED JENKINS-4525] XML encoding sniffing can fail with old JAXP. Modified to assume UTF-8 if we fail to find it.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1205
          [FIXED JENKINS-4525] XML encoding sniffing can fail with old JAXP.

          Kohsuke Kawaguchi : d2c9d7346f0b6f1a66ea466602eb5a79b2730931
          Files :

          • changelog.html
          • core/src/main/java/hudson/XmlFile.java

          dogfood added a comment - Integrated in jenkins_main_trunk #1205 [FIXED JENKINS-4525] XML encoding sniffing can fail with old JAXP. Kohsuke Kawaguchi : d2c9d7346f0b6f1a66ea466602eb5a79b2730931 Files : changelog.html core/src/main/java/hudson/XmlFile.java

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/XmlFile.java
          core/src/main/java/hudson/model/AbstractItem.java
          http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533
          Log:
          [FIXED JENKINS-4525]

          I'd like to believe that the original reason was because earlier
          versions of XStream that we used early on didn't support the methods
          that take InputStream as a parameter.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/XmlFile.java core/src/main/java/hudson/model/AbstractItem.java http://jenkins-ci.org/commit/jenkins/599888fec1de7e64e716c4e2bc9f164f3e11d533 Log: [FIXED JENKINS-4525] I'd like to believe that the original reason was because earlier versions of XStream that we used early on didn't support the methods that take InputStream as a parameter.

            Unassigned Unassigned
            jglick Jesse Glick
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: