Skip to content
Permalink
Browse files

[FIXED JENKINS-15445] use Functions#getBuilderDescriptors to select t…

…he matching descriptors

don't check for @DataBoundConstructor. Descriptor may not use it to create instances
  • Loading branch information
ndeloof committed Oct 9, 2012
1 parent 21359dd commit fcfc219e627afaa8b19395674a756fe4dda43e7d
@@ -25,6 +25,7 @@
package org.jenkinsci.plugins.conditionalbuildstep.lister;

import hudson.Extension;
import hudson.Functions;
import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.model.Hudson;
@@ -49,10 +50,11 @@ public DefaultBuilderDescriptorLister() {
}

public List<? extends Descriptor<? extends BuildStep>> getAllowedBuilders(final AbstractProject<?, ?> project) {
final List<BuildStepDescriptor<? extends Builder>> builders = new ArrayList<BuildStepDescriptor<? extends Builder>>();
final List<Descriptor<? extends Builder>> builders = new ArrayList<Descriptor<? extends Builder>>();
if (project == null)
return builders;
for (Descriptor<Builder> descriptor : Builder.all()) {

for (Descriptor<Builder> descriptor : Functions.getBuilderDescriptors(project)) {
if (descriptor instanceof SingleConditionalBuilder.SingleConditionalBuilderDescriptor) {
continue;
}
@@ -62,12 +64,7 @@ public DefaultBuilderDescriptorLister() {
if (descriptor instanceof BuilderChain.DescriptorImpl) {
continue;
}
if (!(descriptor instanceof BuildStepDescriptor)) {
continue;
}
BuildStepDescriptor<? extends Builder> buildStepDescriptor = (BuildStepDescriptor) descriptor;
if (buildStepDescriptor.isApplicable(project.getClass()) && hasDbc(buildStepDescriptor.clazz))
builders.add(buildStepDescriptor);
builders.add(descriptor);
}
return builders;
}
@@ -76,14 +73,6 @@ public DescriptorImpl getDescriptor() {
return Hudson.getInstance().getDescriptorByType(DescriptorImpl.class);
}

private boolean hasDbc(final Class<?> clazz) {
for (Constructor<?> constructor : clazz.getConstructors()) {
if (constructor.isAnnotationPresent(DataBoundConstructor.class))
return true;
}
return false;
}

@Extension
public static class DescriptorImpl extends Descriptor<BuilderDescriptorLister> {

0 comments on commit fcfc219

Please sign in to comment.
You can’t perform that action at this time.