ExtensionList.lookupSingleton(): Expected 1 instance of org.example.FooStore but got 2

15 views
Skip to first unread message

Thomas Weißschuh

unread,
Jul 15, 2019, 5:12:46 AM7/15/19
to Jenkins Dev
Hello all,

Recently I encountered the following exception while deploying an plugin to our
acceptance jenkins instance:

java.lang.IllegalStateException: Expected 1 instance of org.example.FooStore but got 2
at hudson.ExtensionList.lookupSingleton(ExtensionList.java:450)
at org.example.MyFlowExecutionListener.onRunning(MyFlowExecutionListener.java:33)
at org.jenkinsci.plugins.workflow.flow.FlowExecutionListener.fireRunning(FlowExecutionListener.java:54)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:321)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)

As I am not sure how this could have happened and was so far not able to
reproduce the issue I am asking here, hoping somebody experienced this before
and knows the reason.
Unfortunately the Jenkins instance has been rolled back and I can't provide
more logs.

The duplicate extension is defined and used onlu in this plugin. No other
plugin can provide an extension for this.
After the rollback I tried to lookup the extension via the groovy console and
none was found (technically the class to load itself was missing as expected).

Some information about the system:

* Jenkins version: 2.164.3
* Plugin was dynamically loadable
* Plugin was installed via the "Upload file" functionality of the upload
center
* The `FooStore` component is *always* looked up via `.lookupSingleton()`
* The `FooStore` component is not part of any class hierarchy and is not
Describable/has no descriptor
* The plugin was installed in the past (but was uninstalled again) and the
following leftovers did still exist (these are compatible with the newly
deployed version):
* Configuration XML (for another component)
* Actions attached to builds (No serialized state besides two Strings)
* Builds were executing during the installation
* The plugin has worked hundreds of times while executed with the test harness,
also so far I was not able reproduce the issue when manually installing it

This looks like a fundamental problem of my plugin structure or a race
condition somewhere in the plugin loading or lookup mechanism.

Any pointers are appreciated.

Thanks,
Thomas
Reply all
Reply to author
Forward
0 new messages