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

Wrong HTTP status code when Internal server error occurs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 1.648, Winstone 2.9, JDK 8u65

      Hi,

      When the "Error: Exception" with a stack trace was produced, the Jenkins winstone service reported a healthy HTTP 200 status code. I believe this should have reported an HTTP 500 internal server error. Here's how the status codes should be as I see it...

      • HTTP 503 Service Unavailable - Jenkins is booting, please wait...
      • HTTP 403 forbidden - accessing resources not authorized.
      • HTTP 401 authorization required - accessing URLs while not authenticated.
      • HTTP 500 Internal server error - an internal Jenkins exception occurred.

      Use case
      I encounter issues when upgrading:

      • Folders plugin from 5.1 to 5.2.1
      • Matrix Authorization Strategy Plugin from 1.2 to 1.3.

      hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
      at hudson.WebAppMain$3.run(WebAppMain.java:237)
      Caused by: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
      at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269)
      at jenkins.InitReactorRunner.run(InitReactorRunner.java:44)
      at jenkins.model.Jenkins.executeReactor(Jenkins.java:935)
      at jenkins.model.Jenkins.<init>(Jenkins.java:816)
      at hudson.model.Hudson.<init>(Hudson.java:83)
      at hudson.model.Hudson.<init>(Hudson.java:79)
      at hudson.WebAppMain$3.run(WebAppMain.java:225)
      Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
      at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
      at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:176)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
      at jenkins.model.Jenkins$8.runTask(Jenkins.java:924)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:106)
      ... 8 more
      Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      at java.util.ArrayList.get(ArrayList.java:429)
      at hudson.ExtensionList.get(ExtensionList.java:171)
      at hudson.PluginManager$PluginUpdateMonitor.getInstance(PluginManager.java:1347)
      at hudson.maven.PluginImpl.init(PluginImpl.java:58)
      ... 13 more

      Some additional notes:

      Workaround

      if [ "200" = "$(curl -sLI -w "%{http_code}\\n" -o /dev/null http://localhost:8080)" ] && curl -sL http://localhost:8080 | grep Exception &> /dev/null; then 
      echo "Jenkins Error" 
      fi
      

            danielbeck Daniel Beck
            mgaunin Mikael Gaunin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: