Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE Analysis failure against core branch when PR analysis marked as CANCELLED #298

Closed
jgrant216 opened this issue Jan 29, 2021 · 2 comments

Comments

@jgrant216
Copy link
Contributor

TL;DR: A PR against develop had its analysis task marked as CANCELLED. There was only one analysis, none prior. develop analysis fails due to missing analysisDate element in child CANCELLED PR.

Workflow...

  1. PR-71 submitted against core branch develop.
  2. PR-71 analysis background task on SQ marked as CANCELLED.
  3. CI for PR-71 does not validate SQ was successful, PR-71 was merged to develop.
  4. develop CI runs, EXECUTION FAILURE because call to http://SQHost/api/project_pull_requests/list?project=thisprojectkey returned analysis for key 71 (PR-71) which is missing analysisDate element.

CANCELLED PR Analysis Sample JSON response...
{
"key":"71",
"title":"feature/testingDIT",
"branch":"feature/testingDIT",
"base":"develop",
"status":{
"bugs":0,
"vulnerabilities":0,
"codeSmells":0
},
"target":"develop"
},

Good PR Analysis Sample JSON response...
{
"key":"65",
"title":"feature/db_changes_with_vault_only",
"branch":"feature/db_changes_with_vault_only",
"base":"develop",
"status":{
"qualityGateStatus":"OK",
"bugs":0,
"vulnerabilities":0,
"codeSmells":0
},
"analysisDate":"2021-01-22T13:00:19-0500",
"target":"develop"
},

Environment:

  • Community EditionVersion 8.4.2 (build 36762)
  • Community Branch Plugin 1.5.0
  • CLI 4.6.0.2311

Stack trace with -X including reported plugin information...
13:33:55.831 INFO: Load/download plugins (done) | time=9431ms
13:33:56.417 DEBUG: Plugins:
13:33:56.417 DEBUG: * Python Code Quality and Security 2.13.0.7236 (python)
13:33:56.417 DEBUG: * SonarCSS 1.2.0.1325 (cssfamily)
13:33:56.417 DEBUG: * JaCoCo 1.1.0.898 (jacoco)
13:33:56.417 DEBUG: * SonarGo 1.6.0.719 (go)
13:33:56.417 DEBUG: * SonarKotlin 1.5.0.315 (kotlin)
13:33:56.417 DEBUG: * Azure Active Directory (AAD) Authentication Plug-in for SonarQube 1.2.0 (authaad)
13:33:56.417 DEBUG: * Svn 1.10.0.1917 (scmsvn)
13:33:56.417 DEBUG: * SonarJS 6.2.2.13315 (javascript)
13:33:56.417 DEBUG: * SonarRuby 1.5.0.315 (ruby)
13:33:56.418 DEBUG: * SonarScala 1.5.0.315 (sonarscala)
13:33:56.418 DEBUG: * C# Code Quality and Security 8.9.0.19135 (csharp)
13:33:56.418 DEBUG: * Findbugs 4.0.0 (findbugs)
13:33:56.418 DEBUG: * Groovy 1.6 (groovy)
13:33:56.418 DEBUG: * Java Code Quality and Security 6.5.1.22586 (java)
13:33:56.418 DEBUG: * SonarHTML 3.2.0.2082 (web)
13:33:56.419 DEBUG: * Git 1.12.1.2064 (scmgit)
13:33:56.419 DEBUG: * SonarFlex 2.5.1.1831 (flex)
13:33:56.419 DEBUG: * SonarXML 2.0.1.2020 (xml)
13:33:56.419 DEBUG: * PHP Code Quality and Security 3.5.0.5655 (php)
13:33:56.419 DEBUG: * SonarTS 2.1.0.4359 (typescript)
13:33:56.420 DEBUG: * Checkstyle 8.35 (checkstyle)
13:33:56.420 DEBUG: * VB.NET Code Quality and Security 8.9.0.19135 (vbnet)
13:33:56.420 DEBUG: * Community Branch Plugin 1.5.0 (communityBranchPlugin)
13:33:57.014 INFO: Process project properties
13:33:57.015 INFO: Process project properties (done) | time=1ms
13:33:57.015 INFO: Execute project builders
13:33:57.016 DEBUG: Execute project builder: org.sonar.plugins.csharp.CSharpGlobalProtobufFileProcessor
13:33:57.018 DEBUG: Execute project builder: org.sonar.plugins.vbnet.VbNetGlobalProtobufFileProcessor
13:33:57.021 INFO: Execute project builders (done) | time=6ms
13:33:57.024 INFO: Project key: foo
13:33:57.024 INFO: Base dir: /home/jenkins/workspace/workspace/foo_develop
13:33:57.024 INFO: Working dir: /home/jenkins/workspace/workspace/foo_develop/.scannerwork
13:33:57.024 DEBUG: Project global encoding: UTF-8, default locale: en
13:33:57.026 DEBUG: Creating module hierarchy
13:33:57.026 DEBUG: Init module 'foo'
13:33:57.026 DEBUG: Base dir: /home/jenkins/workspace/workspace/foo_develop
13:33:57.026 DEBUG: Working dir: /home/jenkins/workspace/workspace/foo_develop/.scannerwork
13:33:57.026 DEBUG: Module global encoding: UTF-8, default locale: en
13:33:57.097 INFO: Load project settings for component key: 'foo'
13:33:57.121 DEBUG: GET 200 http://foo/api/settings/values.protobuf?component=foo | time=24ms
13:33:57.123 INFO: Load project settings for component key: 'foo' (done) | time=26ms
13:33:57.185 INFO: Load project branches
13:33:57.205 DEBUG: GET 200 http://foo/api/project_branches/list?project=foo | time=19ms
13:33:57.212 INFO: Load project branches (done) | time=27ms
13:33:57.214 INFO: Load project pull requests
13:33:57.251 DEBUG: GET 200 http://foo/api/project_pull_requests/list?project=foo | time=37ms
13:33:57.270 INFO: ------------------------------------------------------------------------
13:33:57.270 INFO: EXECUTION FAILURE
13:33:57.270 INFO: ------------------------------------------------------------------------
13:33:57.270 INFO: Total time: 13.171s
13:33:57.304 INFO: Final Memory: 9M/80M
13:33:57.304 INFO: ------------------------------------------------------------------------
13:33:57.304 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:66)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034)
at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component interface org.sonar.scanner.scan.branch.BranchConfiguration
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:66)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
... 34 more
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.branch.ProjectPullRequests
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:66)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
... 48 more
Caused by: java.lang.NullPointerException
at com.github.mc1arke.sonarqube.plugin.scanner.CommunityProjectPullRequestsLoader.lambda$createPullRequestInfoJsonDeserialiser$0(CommunityProjectPullRequestsLoader.java:74)
at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at com.google.gson.Gson.fromJson(Gson.java:932)
at com.google.gson.Gson.fromJson(Gson.java:870)
at com.github.mc1arke.sonarqube.plugin.scanner.CommunityProjectPullRequestsLoader.load(CommunityProjectPullRequestsLoader.java:93)
at org.sonar.scanner.scan.branch.ProjectPullRequestsProvider.provide(ProjectPullRequestsProvider.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
... 63 more

jgrant216 added a commit to jgrant216/sonarqube-community-branch-plugin that referenced this issue Jan 29, 2021
jgrant216 added a commit to jgrant216/sonarqube-community-branch-plugin that referenced this issue Jan 29, 2021
@jgrant216
Copy link
Contributor Author

PR submitted - #299

yzhoholiev pushed a commit to yzhoholiev/sonarqube-community-branch-plugin that referenced this issue Feb 18, 2021
mc1arke pushed a commit that referenced this issue Mar 6, 2021
…s is rescanned

When a background task for a pull request analysis is cancelled, a subsequent attempt to re-scan the pull request fails in the scanner since the `analysisDate` field is no longer present against the pull request. This change handles this missing date in a better manner, defaulting to having a `0` analysis date in the same way an error parsing the analysis date would.
@mc1arke
Copy link
Owner

mc1arke commented Apr 1, 2021

Fixed in 1.7.0 of the plugin

@mc1arke mc1arke closed this as completed Apr 1, 2021
gauee pushed a commit to gauee/sonarqube-community-branch-plugin that referenced this issue Feb 16, 2022
…analysis is rescanned

When a background task for a pull request analysis is cancelled, a subsequent attempt to re-scan the pull request fails in the scanner since the `analysisDate` field is no longer present against the pull request. This change handles this missing date in a better manner, defaulting to having a `0` analysis date in the same way an error parsing the analysis date would.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants