Skip to content

Commit

Permalink
[JENKINS-74898] Avoid un-necessary TransientActionFactory consults (#306
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Dohbedoh authored Nov 22, 2024
1 parent 6c81545 commit b239645
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
@Extension
public class SonarBuildBadgeActionFactory extends TransientActionFactory<Run> {

@Override
public Class<? extends Action> actionType() {
return SonarBuildBadgeAction.class;
}

@Override
public Class<Run> type() {
return Run.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public SonarProjectActionFactory() {
resolver = new SQProjectResolver(new HttpClient(OkHttpClientSingleton.getInstance()));
}

@Override
public Class<? extends Action> actionType() {
return ProminentProjectAction.class;
}

@Override
public Class<Job> type() {
return Job.class;
Expand All @@ -66,7 +71,7 @@ public Collection<? extends Action> createFor(Job project) {
Run<?, ?> lastBuild = project.getLastCompletedBuild();

if (lastBuild != null) {
for (SonarAnalysisAction a : lastBuild.getActions(SonarAnalysisAction.class)) {
for (SonarAnalysisAction a : SonarUtils.getPersistentActions(lastBuild, SonarAnalysisAction.class)) {
if (a.getUrl() != null && !urls.contains(a.getUrl())) {
urls.add(a.getUrl());
sonarProjectActions.add(new SonarProjectIconAction(a));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void mockProject(boolean markProject, SonarAnalysisAction... buildInfos)
when(project.getLastCompletedBuild()).thenReturn(build);

if (markProject) {
when(build.getActions(SonarAnalysisAction.class)).thenReturn(Arrays.asList(buildInfos));
when(build.getActions()).thenReturn(Arrays.asList(buildInfos));
when(project.getActions()).thenReturn(Collections.singletonList(new SonarMarkerAction()));
}
}
Expand Down

0 comments on commit b239645

Please sign in to comment.