]> source.dussan.org Git - sonarqube.git/commitdiff
Intern strings in Components and Changesets
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 30 Jul 2019 20:43:07 +0000 (15:43 -0500)
committerSonarTech <sonartech@sonarsource.com>
Wed, 4 Sep 2019 18:21:03 +0000 (20:21 +0200)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scm/Changeset.java

index ac7439d2e8e2db6a24e2253e0cc51e700bcc0263..e9f90f8621cc03b403bb76147169783814714bf9 100644 (file)
@@ -60,7 +60,7 @@ public class ComponentImpl implements Component {
     this.dbKey = builder.dbKey;
     this.key = MoreObjects.firstNonNull(builder.key, builder.dbKey);
     this.name = builder.name;
-    this.shortName = MoreObjects.firstNonNull(builder.shortName, builder.name);
+    this.shortName = MoreObjects.firstNonNull(builder.shortName, builder.name).intern();
     this.description = builder.description;
     this.uuid = builder.uuid;
     this.projectAttributes = builder.projectAttributes;
index 688b514ab5eee2c8673b469b2c820265a9e8132f..9c042f30f4c56a650efb2e0a4f04f6073eda88e5 100644 (file)
@@ -342,9 +342,10 @@ public class ComponentTreeBuilder {
   private static FileAttributes createFileAttributes(ScannerReport.Component component) {
     checkArgument(component.getType() == ScannerReport.Component.ComponentType.FILE);
     checkArgument(component.getLines() > 0, "File '%s' has no line", component.getProjectRelativePath());
+    String lang = trimToNull(component.getLanguage());
     return new FileAttributes(
       component.getIsTest(),
-      trimToNull(component.getLanguage()),
+      lang != null ? lang.intern() : null,
       component.getLines());
   }
 
index 24d86ee6666cb4fa2baadc7a499faaaa845af7bc..df2e63a27d208491ac6d12f93502d30b2cdade73 100644 (file)
@@ -35,8 +35,8 @@ public final class Changeset {
   private final String author;
 
   private Changeset(Builder builder) {
-    this.revision = builder.revision == null ? null : builder.revision.intern();
-    this.author = builder.author == null ? null : builder.author.intern();
+    this.revision = builder.revision;
+    this.author = builder.author;
     this.date = builder.date;
   }