SonarQube Plugins
  1. SonarQube Plugins
  2. SONARPLUGINS-2891

NPE thrown by the 'RegularExpressionCheck' rule

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: WEB-1.2
    • Fix Version/s: WEB-2.0
    • Component/s: Web
    • Labels:
      None
    • Number of attachments :
      0

      Description

      When the regular expression check is enabled with the scope 'attribute', it can fail with a NPE on inputs such as:

      <foo bar />
      

      The 'bar' attribute has no value, and is therefore null.

      The stacktrace looks like:

      [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project web-test: Can not execute Sonar: NullPointerException -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project web-test: Can not execute
      Sonar
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
              at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
              at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
              at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:601)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
              at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:118)
              at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:65)
              at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:90)
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
              ... 19 more
      Caused by: java.lang.NullPointerException
              at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
              at java.util.regex.Matcher.reset(Matcher.java:308)
              at java.util.regex.Matcher.<init>(Matcher.java:228)
              at java.util.regex.Pattern.matcher(Pattern.java:1088)
              at org.sonar.plugins.web.checks.generic.RegularExpressionCheck.startElement(RegularExpressionCheck.java:73)
              at org.sonar.plugins.web.visitor.PageScanner.scanElement(PageScanner.java:78)
              at org.sonar.plugins.web.visitor.PageScanner.scan(PageScanner.java:60)
              at org.sonar.plugins.web.core.WebSensor.analyse(WebSensor.java:85)
              at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
              at org.sonar.batch.phases.Phases.execute(Phases.java:97)
              at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:128)
              at org.sonar.batch.bootstrap.Module.start(Module.java:83)
              at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:114)
              at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:104)
              at org.sonar.batch.bootstrap.Module.start(Module.java:83)
              at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
              at org.sonar.batch.bootstrap.Module.start(Module.java:83)
              at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:73)
              at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:60)
              at org.sonar.maven3.SonarMojo.execute(SonarMojo.java:142)
              at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:113)
              ... 23 more
      

        Activity

        Hide
        Dinesh Bolkensteyn added a comment -

        Should be done.

        I dont really like this rule in general, it's too generic, especially because of the 'scope' parameter.

        But it was already existing

        Show
        Dinesh Bolkensteyn added a comment - Should be done. I dont really like this rule in general, it's too generic, especially because of the 'scope' parameter. But it was already existing
        Hide
        Freddy Mallet added a comment -

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

          • Assignee:
            Dinesh Bolkensteyn
            Reporter:
            David RACODON
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: