Skip to content

Commit b2fa6d1

Browse files
committed
Remove references to ChildNameGenerator.beforeCreateItem
1 parent 43d8bbd commit b2fa6d1

File tree

3 files changed

+24
-35
lines changed

3 files changed

+24
-35
lines changed

src/main/java/jenkins/branch/MultiBranchProject.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package jenkins.branch;
2626

27-
import com.cloudbees.hudson.plugins.folder.ChildNameGenerator;
2827
import com.cloudbees.hudson.plugins.folder.FolderIcon;
2928
import com.cloudbees.hudson.plugins.folder.computed.ChildObserver;
3029
import com.cloudbees.hudson.plugins.folder.computed.ComputedFolder;
@@ -2092,21 +2091,16 @@ private void observeExisting(@NonNull SCMHead head, @NonNull SCMRevision revisio
20922091
}
20932092

20942093
private void observeNew(@NonNull SCMHead head, @NonNull SCMRevision revision, @NonNull Branch branch, String rawName, String encodedName, Action[] revisionActions) {
2095-
P project;
20962094
if (!observer.mayCreate(encodedName)) {
20972095
listener.getLogger().println("Ignoring duplicate branch project " + rawName);
20982096
return;
20992097
}
2100-
try (ChildNameGenerator.Trace trace = ChildNameGenerator.beforeCreateItem(
2101-
MultiBranchProject.this, encodedName, branch.getName()
2102-
)) {
2103-
if (getItem(encodedName) != null) {
2104-
throw new IllegalStateException(
2105-
"JENKINS-42511: attempted to redundantly create " + encodedName + " in "
2106-
+ MultiBranchProject.this);
2107-
}
2108-
project = _factory.newInstance(branch);
2098+
if (getItem(encodedName) != null) {
2099+
throw new IllegalStateException(
2100+
"JENKINS-42511: attempted to redundantly create " + encodedName + " in "
2101+
+ MultiBranchProject.this);
21092102
}
2103+
P project = _factory.newInstance(branch);
21102104
if (!project.getName().equals(encodedName)) {
21112105
throw new IllegalStateException(
21122106
"Name of created project " + project + " did not match expected " + encodedName);

src/main/java/jenkins/branch/MultiBranchProjectDescriptor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ public String itemNameFromItem(@NonNull MultiBranchProject<P,R> parent, @NonNull
231231
if (factory.isProject(item)) {
232232
return NameEncoder.encode(factory.getBranch(item).getName());
233233
}
234-
String idealName = idealNameFromItem(parent, item);
235-
if (idealName != null) {
236-
return NameEncoder.encode(idealName);
234+
String name = item.getName();
235+
if (name != null) {
236+
return NameEncoder.encode(name);
237237
}
238238
return null;
239239
}
@@ -245,9 +245,9 @@ public String dirNameFromItem(@NonNull MultiBranchProject<P,R> parent, @NonNull
245245
if (factory.isProject(item)) {
246246
return NameMangler.apply(factory.getBranch(item).getName());
247247
}
248-
String idealName = idealNameFromItem(parent, item);
249-
if (idealName != null) {
250-
return NameMangler.apply(idealName);
248+
String name = item.getName();
249+
if (name != null) {
250+
return NameMangler.apply(name);
251251
}
252252
return null;
253253
}

src/main/java/jenkins/branch/OrganizationFolder.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,9 @@ public String itemNameFromItem(@NonNull OrganizationFolder parent, @NonNull Mult
852852
if (property != null) {
853853
return NameEncoder.encode(property.getName());
854854
}
855-
String idealName = idealNameFromItem(parent, item);
856-
if (idealName != null) {
857-
return NameEncoder.encode(idealName);
855+
String name = item.getName();
856+
if (name != null) {
857+
return NameEncoder.encode(name);
858858
}
859859
return null;
860860
}
@@ -866,9 +866,9 @@ public String dirNameFromItem(@NonNull OrganizationFolder parent, @NonNull Multi
866866
if (property != null) {
867867
return NameMangler.apply(property.getName());
868868
}
869-
String idealName = idealNameFromItem(parent, item);
870-
if (idealName != null) {
871-
return NameMangler.apply(idealName);
869+
String name = item.getName();
870+
if (name != null) {
871+
return NameMangler.apply(name);
872872
}
873873
return null;
874874
}
@@ -1436,19 +1436,14 @@ private void completeNew(MultiBranchProjectFactory factory, Map<String, Object>
14361436
.println("Ignoring duplicate child " + projectName + " named " + folderName);
14371437
return;
14381438
}
1439-
MultiBranchProject<?, ?> project;
1440-
try (ChildNameGenerator.Trace trace = ChildNameGenerator.beforeCreateItem(
1441-
OrganizationFolder.this, folderName, projectName
1442-
)) {
1443-
if (getItem(folderName) != null) {
1444-
throw new IllegalStateException(
1445-
"JENKINS-42511: attempted to redundantly create " + folderName + " in "
1446-
+ OrganizationFolder.this);
1447-
}
1448-
project = factory.createNewProject(
1449-
OrganizationFolder.this, folderName, sources, attributes, listener
1450-
);
1439+
if (getItem(folderName) != null) {
1440+
throw new IllegalStateException(
1441+
"JENKINS-42511: attempted to redundantly create " + folderName + " in "
1442+
+ OrganizationFolder.this);
14511443
}
1444+
MultiBranchProject<?, ?> project = factory.createNewProject(
1445+
OrganizationFolder.this, folderName, sources, attributes, listener
1446+
);
14521447
BulkChange bc = new BulkChange(project);
14531448
try {
14541449
if (!projectName.equals(folderName)) {

0 commit comments

Comments
 (0)