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

The error message is meaningless when a project contains duplicate source files

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: None
    • Labels:
      None

      Description

      I got the following exception in a sonar analysis:

      [sonar:sonar] 19:27:26.492 INFO Initializer ProjectFileSystemLogger done: 19 ms
      [sonar:sonar] 19:27:26.861 INFO Sensor JavaSourceImporter...
      [sonar:sonar] org.sonar.api.utils.SonarException: Unable to read and import the source file : '/home/[..]/BSExceptionParameter.java' with the charset : 'ISO-8859-1'.
      

      This message is highly missleading. Users get the idea that the problem is file encoding (e. g. see SONAR-3158 where somebody using Maven got a similar exception and was convinced that the problem is file encoding even though he could prove that it wasn't).

      Only running the analysis with ant -v -d reveals the real problem: a duplicate source file: org.sonar.api.resources.DuplicatedSourceException (see stack trace below).

      => The Ant-Task should log a stack trace or at least the exception that causes the failure, not some meaningless message (and certainly not a message that gives you wrong ideas).

      (NB: I can remember seeing the 'DuplicatedSourceException' in regular Ant output before - has this changed with Sonar ANT-Task 1.3?)

      ===============
      Ant output:

      	at org.apache.tools.ant.Target.performTasks(Target.java:411)
      	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
      	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:442)
      	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      	at org.apache.tools.ant.Task.perform(Task.java:348)
      	at org.apache.tools.ant.Target.execute(Target.java:390)
      	at org.apache.tools.ant.Target.performTasks(Target.java:411)
      	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
      	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      	at org.apache.tools.ant.Main.runBuild(Main.java:809)
      	at org.apache.tools.ant.Main.startAnt(Main.java:217)
      	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
      	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
      Caused by: org.sonar.api.resources.DuplicatedSourceException: ch.css.bs.runtime.BSExceptionParameter
      	at org.sonar.batch.index.SourcePersister.saveSource(SourcePersister.java:45)
      	at org.sonar.batch.index.DefaultPersistenceManager.setSource(DefaultPersistenceManager.java:78)
      	at org.sonar.batch.index.DefaultIndex.setSource(DefaultIndex.java:402)
      	at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:159)
      	at org.sonar.plugins.squid.JavaSourceImporter.importSource(JavaSourceImporter.java:83)
      	... 61 more
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fabemn OLD - Fabrice Bellingard
              Reporter:
              mystermask Myster Mask
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: