Skip to content

Commit 783c139

Browse files
committed
[JENKINS-57694] Fix calling SpecificRevisionBuildChooser#getDisplayName()
There may be `BuildChooser`s that don't have a `Descriptor` because they are not meant to be selectable by a user in the UI. Currently `SpecificRevisionBuildChooser` is such a `BuildChooser`. This missing `Descriptor` was causing an exception when `BuildChooser#getDisplayName()` was called within `GitSCM#compareRemoteRevisionWithImpl()` to log its name. The `Descriptor` was once already in place but then removed in commit 75e7880 because the `SpecificRevisionBuildChooser` is not meant to be selectable by a user in the UI. Therefore the absence of a `Descriptor` has to be handled.
1 parent 529edcd commit 783c139

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/hudson/plugins/git/util/BuildChooser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import hudson.DescriptorExtensionList;
88
import hudson.ExtensionPoint;
99
import hudson.model.Describable;
10+
import hudson.model.Descriptor;
1011
import jenkins.model.Jenkins;
1112
import hudson.model.Item;
1213
import hudson.model.TaskListener;
@@ -46,9 +47,10 @@ public abstract class BuildChooser implements ExtensionPoint, Describable<BuildC
4647
* @return display name of this build chooser
4748
*/
4849
public final String getDisplayName() {
49-
return getDescriptor().getDisplayName();
50+
Descriptor<?> descriptor = Jenkins.get().getDescriptor(getClass());
51+
return descriptor != null ? descriptor.getDisplayName() : getClass().getSimpleName();
5052
}
51-
53+
5254
/**
5355
* Get a list of revisions that are candidates to be built.
5456
*

0 commit comments

Comments
 (0)