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

NullPointerException might happen when analysing a Java project and when the rule 'squid:S1228' is activated

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.5.1, 5.0
    • Fix Version/s: 4.5.6, 5.2
    • Component/s: Scanner
    • Labels:
      None

      Description

      Way to reproduce this issue :

      • Activate rule squid:S1228
      • A Java source located in a root directory and this root directory is also the base directory ( sonar.sources=.)
      • No package-info.java file in the root folder of the project
      • Launch a Java analysis -> NullPointerException (see below)

      Here are some potential workarounds:

      • Disable squid:S1228
      • Or put files in a source folder
      • Or add a package-info.java at the root of the project
      [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project customfiles-transformation-mediation-bundle: null: MojoExecutionException: NullPointerException -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project customfiles-transformation-mediation-bundle: null
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
      	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:116)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
      	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
      	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:606)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
      Caused by: org.apache.maven.plugin.MojoExecutionException
      	at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
      	at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
      	at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
      	... 19 more
      Caused by: java.lang.NullPointerException
      	at org.sonar.api.resources.Resource.hashCode(Resource.java:305)
      	at java.util.HashMap.hash(HashMap.java:362)
      	at java.util.HashMap.put(HashMap.java:492)
      	at java.util.HashSet.add(HashSet.java:217)
      	at org.sonar.plugins.java.bridges.ChecksBridge.initSetOfDirs(ChecksBridge.java:130)
      	at org.sonar.plugins.java.bridges.ChecksBridge.reportIssueForPackageInfo(ChecksBridge.java:110)
      	at org.sonar.plugins.java.Bridges.reportIssues(Bridges.java:66)
      	at org.sonar.plugins.java.Bridges.save(Bridges.java:61)
      	at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:87)
      	at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
      	at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:7
      

        Attachments

          Activity

            People

            • Assignee:
              julien.henry Julien Henry
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: