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

Discard Unreadable Data leads to NPE in TreeMap.putAll

    • Jenkins 2.166

      On our instance, Jenkins reports unreadable data of types hudson.maven.MavenModuleSet, hudson.model.Fingerprint, hudson.model.FreeStyleProject, hudson.maven.MavenModuleSetBuild and org.jenkinsci.plugins.DependencyCheck.DependencyCheckBuilder$DescriptorImpl.

      When clicking on the discard button, Jenkins displays the following stacktrace.

      javax.servlet.ServletException: java.lang.NullPointerException
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:796)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
      	at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236)
      	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
      	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
      	at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
      	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132)
      	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:49)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
      	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
      	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.NullPointerException
      	at java.util.TreeMap.putAll(TreeMap.java:313)
      	at java.util.TreeMap.<init>(TreeMap.java:185)
      	at hudson.model.Fingerprint.toString(Fingerprint.java:1412)
      	at java.lang.String.valueOf(String.java:2994)
      	at java.lang.StringBuilder.append(StringBuilder.java:131)
      	at hudson.diagnosis.OldDataMonitor.saveAndRemoveEntries(OldDataMonitor.java:365)
      	at hudson.diagnosis.OldDataMonitor.doDiscard(OldDataMonitor.java:335)
      	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:498)
      	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335)
      	at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:52)
      	at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
      	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175)
      	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108)
      	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124)
      	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
      	... 67 more
      

      As the Stacktrace mentions the Fingerprint.toString method (see source code for that release), here is one of the errors reported for the unreadable hudson.model.Fingerprint data:

      ConversionException: : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7) : : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7) ---- Debugging information ---- message : : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7) cause-exception : com.thoughtworks.xstream.io.StreamException cause-message : : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7) class : java.util.Hashtable required-type : java.util.Hashtable converter-type : hudson.util.RobustMapConverter path : /fingerprint/usages/entry[183] line number : 738 -------------------------------, MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint', MissingFieldException: No field 'entry' found in class 'hudson.model.Fingerprint'
      

      Please note, that this error does not seem to be related to JENKINS-18809 or JENKINS-17125. The former yields a NPE in hudson.model.AbstractItem.getRootDir, the latter in hudson.model.AbstractBuild.getPreviousBuild. The NPE in this bug ticket occurs in java.util.TreeMap.putAll.

      A last thing to note, is that the error seems to occur during logging another exception in OldDataMonitor.saveAndRemoveEntires (see source code for that release).

          [JENKINS-43218] Discard Unreadable Data leads to NPE in TreeMap.putAll

          Oleg Nenashev added a comment - - edited

          The issue is here: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Fingerprint.java#L1412

          Usages variable is supposed to be deserialized from the disk, but according to the ticket reading fails, because there is no "entry" field. I suppose the root cause of this issue is the whatever XStream issue, which causes improper reading of maps.

          fxnn would it be possible to retrieve the XML file for the fingerprint from the disk? It would be useful for diagnostics

          Oleg Nenashev added a comment - - edited The issue is here: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Fingerprint.java#L1412 Usages variable is supposed to be deserialized from the disk, but according to the ticket reading fails, because there is no "entry" field. I suppose the root cause of this issue is the whatever XStream issue, which causes improper reading of maps. fxnn would it be possible to retrieve the XML file for the fingerprint from the disk? It would be useful for diagnostics

          Felix Neumann added a comment - - edited

          oleg_nenashev:

          Okay, at first I didn't find the file, as the file name isn't mentioned in the UI. Now I found it and it contains invalid XML. I searched for the string 7562 mentioned in the error message above and it contains the following (I anonymized the project names):

          d:\jenkins\fingerprints\53\22\792f9f6480dde9de2d2bcc0fda18.xml
              <entry>
                <string>example/com.example:example-common-documents</string>
                <ranges>7562</ranges>
              <   <string>example-it/com.example:example-wos-war</string>
                <ranges>3094,3097</ranges>
              </entry>
          

          This explains the error message ConversionException: : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7).

          I suggest that I could simply delete the five affected files and restart Jenkins, which should allow Jenkins to complete the discard unreadable data action. What do you think?

          Felix Neumann added a comment - - edited oleg_nenashev : Okay, at first I didn't find the file, as the file name isn't mentioned in the UI. Now I found it and it contains invalid XML. I searched for the string 7562 mentioned in the error message above and it contains the following (I anonymized the project names): d:\jenkins\fingerprints\53\22\792f9f6480dde9de2d2bcc0fda18.xml <entry> <string> example/com.example:example-common-documents </string> <ranges> 7562 </ranges> < <string> example-it/com.example:example-wos-war </string> <ranges> 3094,3097 </ranges> </entry> This explains the error message ConversionException: : unexpected character in markup (position: END_TAG seen ...7562</ranges>\r\n < ... @738:7) . I suggest that I could simply delete the five affected files and restart Jenkins, which should allow Jenkins to complete the discard unreadable data action. What do you think?

          Oleg Nenashev added a comment -

          fxnn Sorry for the response delay, missed the notification. Yes, for you the best ways is to fix or to remove the file.

          From the Jenkins core PoV, I suppose we need to be more robust in such case (at least to prevent loading of the corrupted objects). So it's still a bug.

          Oleg Nenashev added a comment - fxnn Sorry for the response delay, missed the notification. Yes, for you the best ways is to fix or to remove the file. From the Jenkins core PoV, I suppose we need to be more robust in such case (at least to prevent loading of the corrupted objects). So it's still a bug.

          Felix Neumann added a comment -

          oleg_nenashev: Deleting the files and restarting Jenkins helped to cleanup the unreadable data.

          Felix Neumann added a comment - oleg_nenashev : Deleting the files and restarting Jenkins helped to cleanup the unreadable data.

          Peter Taucher added a comment - - edited

          fxnn Do you mean deleting the fingerprint files?

          Stopping jenkins, deleting the fingerprints and restarting jenkins did probably solve the issue (the warnings did not show up anymore, so I can't say for sure if the Discard button would now work ; - ).

          Peter Taucher added a comment - - edited fxnn Do you mean deleting the fingerprint files? Stopping jenkins, deleting the fingerprints and restarting jenkins did probably solve the issue (the warnings did not show up anymore, so I can't say for sure if the Discard button would now work ; - ).

          Oleg Nenashev added a comment -

          It seems to be a trivial fix (add checks in the toString() method) 

          Oleg Nenashev added a comment - It seems to be a trivial fix (add checks in the toString() method) 

            foxtrot9 Mit Naria
            fxnn Felix Neumann
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: