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

Analysis fails with a meaningless ArrayIndexOutOfBounds exception if a rule try to log an issue on a non-existing line

    XMLWordPrintable

    Details

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

      Description

      If sensors create issues associated with invalid line numbers (larger than the number of lines in the file or <= 0), the batch will fail with an ArrayIndexOutOfBounds. It is also impossible to know what is the rule causing the error without debugging it.

      Batch should fail fast, giving an appropriate message, including the rule causing the problem.

      {{Example:

      org.sonar.runner.impl.RunnerException: Unable to execute Sonar
      	at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
      	at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
      	at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
      	at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
      	at org.sonar.runner.api.Runner.execute(Runner.java:100)
      	at org.sonar.runner.Main.executeTask(Main.java:70)
      	at org.sonar.runner.Main.execute(Main.java:59)
      	at org.sonar.runner.Main.main(Main.java:53)
      Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@9c98867[key=src/cooral/core/impl/AbstractGestorTpv.java,path=src/cooral/core/impl/AbstractGestorTpv.java,filename=AbstractGestorTpv.java,language=Java]'
      	at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:104)
      	at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:87)
      	at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
      	at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
      	at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:71)
      	at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:127)
      	at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
      	at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      	at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      	at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
      	at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
      	at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
      	at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      	at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      	at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
      	at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
      	at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
      	at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      	at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      	at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
      	at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
      	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
      	at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
      	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.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
      	... 9 more
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 1974
      	at org.sonar.batch.issue.tracking.FileHashes.getHash(FileHashes.java:89)
      	at org.sonar.batch.issue.tracking.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:66)
      	at org.sonar.batch.issue.tracking.IssueTracking.track(IssueTracking.java:51)
      	at org.sonar.batch.issue.tracking.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:139)
      	at org.sonar.batch.issue.tracking.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:113)
      	at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:96)
      	... 36 more
      

      }}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              duarte.meneses Duarte Meneses
              Reporter:
              duarte.meneses Duarte Meneses
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: