Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-11419

Call to /api/components/suggestions can fail with NPE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.4
    • Fix Version/s: 7.5
    • Component/s: Web API
    • Labels:
    • Estimate:
      Minutes
    • Edition:
      Community
    • Production Notes:
      None

      Description

      Call to /api/components/suggestions can fail with NPE such as the following under some conditions:

      2018.10.28 19:15:05 ERROR web[AWavcRDNqXvKZPtMClQT][o.s.s.w.WebServiceEngine] Fail to process request http://sonarcloud.io/api/components/suggestions?s=apta&recentlyBrowsed=hs-b2b-dashboard%2Ccom.sonarsource.website%3Ablog.sonarsource.com
      java.lang.NullPointerException: null
              at org.sonar.server.component.ws.SuggestionsAction.toSuggestion(SuggestionsAction.java:352)
              at org.sonar.server.component.ws.SuggestionsAction.lambda$null$7(SuggestionsAction.java:319)
              at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
              at java.util.Iterator.forEachRemaining(Iterator.java:116)
              at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
              at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
              at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
              at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
              at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
              at org.sonar.server.component.ws.SuggestionsAction.lambda$toCategories$8(SuggestionsAction.java:321)
              at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
              at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
              at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
              at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
              at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
              at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
              at org.sonar.server.component.ws.SuggestionsAction.toCategories(SuggestionsAction.java:328)
              at org.sonar.server.component.ws.SuggestionsAction.toResponse(SuggestionsAction.java:309)
              at org.sonar.server.component.ws.SuggestionsAction.buildResponse(SuggestionsAction.java:279)
              at org.sonar.server.component.ws.SuggestionsAction.loadSuggestionsWithSearch(SuggestionsAction.java:240)
              at org.sonar.server.component.ws.SuggestionsAction.loadSuggestions(SuggestionsAction.java:167)
              at org.sonar.server.component.ws.SuggestionsAction.handle(SuggestionsAction.java:151)
              at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:110)
              at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:88)
              at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
              at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
              at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.CacheControlFilter.doFilter(CacheControlFilter.java:76)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:76)
              at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
              at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
              at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
              at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
              at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
              at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
              at java.lang.Thread.run(Thread.java:748)
      ...
      

      Apparently, this NPE may occur when a search hit returns a non project component (eg. a module, file, ...) which project does not return a search hit itself.

      While there is no known easy way to reproduce the issue, the fix should be a matter of retrieving the ComponentDto not only for the component UUIDs of the search hits, but also of the projects of those components (because NPE occurs here when looking up the ComponentDto of the project of the component).

        Attachments

          Activity

            People

            • Assignee:
              sebastien.lesaint Sebastien Lesaint
              Reporter:
              sebastien.lesaint Sebastien Lesaint
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: