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

After a migration to SonarQube 4.2 new resource key format, potential failure with a "NonUniqueResultException"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.2
    • Fix Version/s: 4.3.2, 4.4
    • Component/s: Scanner
    • Labels:
      None

      Description

      See following thread of discussion : http://markmail.org/message/yu2nmqnlr24st3ir

      Example of stack trace:

      Caused by: org.sonar.api.utils.SonarException: The resource 'foobar-module:test/helper' is duplicated in database.
      	at org.sonar.batch.index.DefaultResourcePersister.findOrCreateModel(DefaultResourcePersister.java:273)
      	at org.sonar.batch.index.DefaultResourcePersister.persistFileOrDirectory(DefaultResourcePersister.java:220)
      	at org.sonar.batch.index.DefaultResourcePersister.persist(DefaultResourcePersister.java:169)
      	at org.sonar.batch.index.DefaultResourcePersister.saveResource(DefaultResourcePersister.java:153)
      	at org.sonar.batch.index.DefaultPersistenceManager.saveResource(DefaultPersistenceManager.java:72)
      	at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:537)
      	at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:500)
      	at org.sonar.batch.index.DefaultIndex.doIndex(DefaultIndex.java:498)
      	at org.sonar.batch.index.DefaultIndex.index(DefaultIndex.java:492)
      	at org.sonar.batch.scan.filesystem.ComponentIndexer.execute(ComponentIndexer.java:82)
      	at org.sonar.batch.scan.filesystem.DefaultModuleFileSystem.index(DefaultModuleFileSystem.java:216)
      	at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:126)
      	at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:186)
      	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:199)
      	at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:194)
      	at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:187)
      	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:56)
      	at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44)
      	at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
      	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.BootstrapContainer.executeTask(BootstrapContainer.java:144)
      	at org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:132)
      	at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      	at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      	at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
      	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
      	at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
      	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:616)
      	at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:75)
      	... 37 more
      Caused by: javax.persistence.NonUniqueResultException: Expected single result for entitiy ResourceModel with criterias : key,foobar-module:test/helper
      	at org.sonar.jpa.session.JpaDatabaseSession.getSingleResult(JpaDatabaseSession.java:241)
      	at org.sonar.batch.index.DefaultResourcePersister.findOrCreateModel(DefaultResourcePersister.java:260)
      	... 73 more
      Caused by: javax.persistence.NonUniqueResultException: Expected single result, but got : [org.sonar.api.database.model.ResourceModel@2a852e54[id=901,key=foobar-module:test/helper,deprecatedKey=foobar-module:helper,scope=DIR,qualifier=DIR,name=helper,longName=helper,lang=java,enabled=true,rootId=677,path=<null>,copyResourceId=<null>,personId=<null>,createdAt=2014-02-09 16:44:34.0], org.sonar.api.database.model.ResourceModel@da4a29b[id=916,key=foobar-module:test/helper,deprecatedKey=<null>,scope=DIR,qualifier=DIR,name=test.helper,longName=test.helper,lang=java,enabled=false,rootId=677,path=<null>,copyResourceId=<null>,personId=<null>,createdAt=2014-02-09 16:44:35.0]]
      	at org.sonar.jpa.session.JpaDatabaseSession.getSingleResult(JpaDatabaseSession.java:218)
      	at org.sonar.jpa.session.JpaDatabaseSession.getSingleResult(JpaDatabaseSession.java:238)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              henryju OLD - Julien HENRY
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: