How does dropdownList work and what can affect the descriptorImpl

12 views
Skip to first unread message

Michael Carter

unread,
May 9, 2022, 1:13:12 PM5/9/22
to Jenkins Developers
This is actually related to https://issues.jenkins.io/browse/JENKINS-67055

Something in my own plugin has caused the same issue and I'm trying to track down what I'm doing that's affecting the org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition$DescriptorImpl instance.

From what I can see in the source of the dropdownlist jelly file, you're comparing memory address hash with...  (from the toString())

selected="${current.descriptor==descriptor || (current==null and descriptor==attrs.default)}"

When I modify that in the jenkins.war to see what's in there I noticed this is what it's seeing.   The only difference is the hashcode.

debug var.....: org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition$DescriptorImpl@72d8eb26 
debug currDesc: org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition$DescriptorImpl@6904e8d2

I'm at a bit of a loss trying to figure out how I'm affecting this object.   Tried looking at the mixing-security-realm-plugin to see what it's doing with no luck either.

One thing I did try is to alter that dropdownlist jelly to:

        selected="${current.descriptor.getClass().getName() == descriptor.getClass().getName() || (current==null and descriptor==attrs.default)}" staplerClass="${descriptor.clazz.name}"
        lazy="descriptor,it,${capture}">


Works fine.   So any ideas where I should look to track down what's going on here?

Daniel Beck

unread,
May 9, 2022, 1:38:26 PM5/9/22
to jenkin...@googlegroups.com
On Mon, May 9, 2022 at 7:13 PM Michael Carter <mikeyca...@gmail.com> wrote:
debug var.....: org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition$DescriptorImpl@72d8eb26 
debug currDesc: org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition$DescriptorImpl@6904e8d2
 
This means there are two different instances of the same descriptor. Descriptors are expected to be instantiated once, typically during load by processing the @Extension annotation. So I'd check whether you're instantiating the descriptor somewhere manually, or otherwise messing with descriptor/extension lists.

Michael Carter

unread,
May 9, 2022, 2:18:44 PM5/9/22
to Jenkins Developers
So if I run this in the script console and only find one:

import jenkins.model.*;

List<Descriptor> d = Jenkins.instance.getExtensionList(Descriptor.class);

for (descriptor in d) {
  println descriptor
}

Would that suggest that whatever I've done is only loaded during the "/configure" page load?   or is that groovy script above wrong?

Michael Carter

unread,
May 9, 2022, 11:30:12 PM5/9/22
to Jenkins Developers
Just to close the loop.  Found it.   

I was using all().get("class") in my code... and for some reason, the Jira plugin was activating it and I was getting duplicates only on the "definition" block of the job page.   Switched to ExtensionList.lookupSinglton() and the problem went away.

Reply all
Reply to author
Forward
0 new messages