Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrent modification exception in ExecuteDslScripts #1253

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private Set<String> updateTemplates(Job seedJob, TaskListener listener,
Collection<SeedReference> seedJobReferences = descriptor.getTemplateJobMap().get(templateName);
Collection<SeedReference> matching = Collections2.filter(seedJobReferences, new SeedNamePredicate(seedJobName));
if (!matching.isEmpty()) {
seedJobReferences.removeAll(matching);
seedJobReferences.removeAll(Sets.newHashSet(matching));
descriptorMutated = true;
}
}
Expand All @@ -432,7 +432,7 @@ private Set<String> updateTemplates(Job seedJob, TaskListener listener,
} else {
if (matching.size() > 1) {
// Not sure how there could be more one, throw it all away and start over
seedJobReferences.removeAll(matching);
seedJobReferences.removeAll(Sets.newHashSet(matching));
}
seedJobReferences.add(new SeedReference(templateName, seedJobName, digest));
descriptorMutated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,24 @@ folder('folder-a/folder-b') {
jenkinsRule.instance.getDescriptorByType(DescriptorImpl).generatedJobMap.size() == 0
}
def "JENKINS-69064 Deleted jobs with different seeds but same templates are removed from GeneratedJobMap"() {
setup:
FreeStyleProject seedJob = jenkinsRule.createFreeStyleProject('seed')
FreeStyleProject seedJob2 = jenkinsRule.createFreeStyleProject('seed2')
jenkinsRule.createFreeStyleProject('template')
runBuild(seedJob, new ExecuteDslScripts('job("test-job") {\n using("template")\n}'))
runBuild(seedJob2, new ExecuteDslScripts('job("test-job-2") {\n using("template")\n}'))
when:
ExecuteDslScripts builder = new ExecuteDslScripts('// do nothing')
builder.removedJobAction = RemovedJobAction.DELETE
runBuild(seedJob, builder)
runBuild(seedJob2, builder)
then:
jenkinsRule.instance.getDescriptorByType(DescriptorImpl).generatedJobMap.size() == 0
}
def "Manually deleted job is removed from GeneratedJobMap"() {
setup:
FreeStyleProject seedJob = jenkinsRule.createFreeStyleProject('seed')
Expand Down