]> source.dussan.org Git - sonarqube.git/commitdiff
Fix ScanPerspectives when resource has a component key
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 30 May 2013 16:26:26 +0000 (18:26 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 30 May 2013 16:26:26 +0000 (18:26 +0200)
sonar-core/src/main/java/org/sonar/core/component/ScanPerspectives.java

index ad8e7b9886b146a67c19f91ddd43471c76f55745..ada1e649958f732ccdaf160b86338985d2dfe0bc 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.component.ResourcePerspectives;
 import org.sonar.api.resources.Resource;
 
 import javax.annotation.CheckForNull;
-
 import java.util.Map;
 
 public class ScanPerspectives implements ResourcePerspectives, BatchComponent {
@@ -55,7 +54,10 @@ public class ScanPerspectives implements ResourcePerspectives, BatchComponent {
 
   @CheckForNull
   public <P extends Perspective> P as(Class<P> perspectiveClass, Resource resource) {
-    Resource indexedResource = resourceIndex.getResource(resource);
+    Resource indexedResource = resource;
+    if (resource.getEffectiveKey() == null) {
+      indexedResource = resourceIndex.getResource(resource);
+    }
     if (indexedResource != null) {
       return as(perspectiveClass, new ResourceComponent(indexedResource));
     }