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

SQ fails to load built-in QP with deprecated key of other plugin

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.9.1
    • Fix Version/s: 7.9.2, 8.1
    • Component/s: Quality Profile
    • Labels:
      None
    • Edition:
      Community
    • Production Notes:
      None

      Description

      WHY

      Language plugins have the ability to change the key of rule.

      In this case, for backward compatibility reasons, the declare the old key as "deprecated" and SonarQube handles the transition nicely (including downgrading the plugin), see MMF-1153.

      However, when another plugin that the one which ships the rule defines a built-in Quality Profile referencing the rule by its deprecated key, SonarQube fails at startup with an error such as the following:

      2019.11.20 08:40:56 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
      java.lang.IllegalStateException: Rule with key 'javascript:VariableDeclarationAfterUsage' not found
      	at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$updateOrCreateBuilder$5(BuiltInQProfileRepositoryImpl.java:188)
      	at java.base/java.util.ArrayList.forEach(Unknown Source)
      	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Unknown Source)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.updateOrCreateBuilder(BuiltInQProfileRepositoryImpl.java:185)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$toQualityProfileBuilders$4(BuiltInQProfileRepositoryImpl.java:164)
      	at java.base/java.util.HashMap.compute(Unknown Source)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.toQualityProfileBuilders(BuiltInQProfileRepositoryImpl.java:162)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.lambda$toFlatList$2(BuiltInQProfileRepositoryImpl.java:133)
      	at org.sonar.core.util.stream.MoreCollectors.lambda$uniqueIndex$9(MoreCollectors.java:258)
      	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source)
      	at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(Unknown Source)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
      	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
      	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.toFlatList(BuiltInQProfileRepositoryImpl.java:131)
      	at org.sonar.server.qualityprofile.BuiltInQProfileRepositoryImpl.initialize(BuiltInQProfileRepositoryImpl.java:81)
      	at org.sonar.server.qualityprofile.BuiltInQProfileLoader.start(BuiltInQProfileLoader.java:37)
      	at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.start(StartableCloseableSafeLifecyleStrategy.java:40)
      	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
      	at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
      	at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
      	at org.picocontainer.behaviors.Stored.start(Stored.java:110)
      	at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
      	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
      	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
      	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
      	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:90)
      	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:47)
      	at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:83)
      	at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:46)
      	at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:80)
      	at org.sonar.server.platform.Platform.executeStartupTasks(Platform.java:196)
      	at org.sonar.server.platform.Platform.access$400(Platform.java:46)
      	at org.sonar.server.platform.Platform$1.lambda$doRun$1(Platform.java:121)
      	at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371)
      	at org.sonar.server.platform.Platform$1.doRun(Platform.java:121)
      	at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355)
      	at java.base/java.lang.Thread.run(Unknown Source)
      

      This error was initially reported on Sonar-JS by a user (see Github issue) and was caused by the codescan plugin.

      Workarounds are:

      1. uninstall codescan
      2. update the codescan plugin to a version compatible with sonar-JS

      WHAT

      Renaming rule key is currently hardly used and the problem occurs only when community plugins exists which provide QP with rules from our language plugins.

      However, there are plans for sonar-java to rename several keys and this plugin is for sure the base of many community plugin.

      Also, new sonar-java and sonar-js plugins target the LTS as well as the latest version of SQ, which implies that LTS should be fixed.

      HOW

      When a quality profile is using deprecate keys of rules, the new rule key should be used instead.

       

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: