Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More helpful error message for ExtensionList.lookupSingleton #8646

Merged
merged 1 commit into from Oct 30, 2023

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 26, 2023

A periodic issue, most recently noticed going over something with @julieheard: if you run JenkinsRule tests using a special test runner from an IDE which does not autodiscover annotation processors, things will be badly broken, and a typical symptom is this otherwise fairly opaque error. If in doubt, use Maven to run tests (and invoke the clean phase to be sure).

Testing done

None, my IDE runs Maven (well, mvnd) to begin with! Edit: #8646 (comment)

Proposed changelog entries

  • N/A

Before the changes are marked as ready-for-merge:

Maintainer checklist

Edit tasklist title
Beta Give feedback Tasklist Maintainer checklist, more options

Delete tasklist

Delete tasklist block?
Are you sure? All relationships in this tasklist will be removed.
  1. There are at least two (2) approvals for the pull request and no outstanding requests for change.
    Options
  2. Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
    Options
  3. Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
    Options
  4. Proper changelog labels are set so that the changelog can be generated automatically.
    Options
  5. If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
    Options
  6. If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).
    Options

@jglick
Copy link
Member Author

jglick commented Oct 26, 2023

Found a way to test, sort of. After

mvnd -am -pl war -Pquick-build install
cd ../branch-api-plugin

and

diff --git src/main/java/jenkins/branch/WorkspaceLocatorImpl.java src/main/java/jenkins/branch/WorkspaceLocatorImpl.java
index 4515492..14d452b 100644
--- src/main/java/jenkins/branch/WorkspaceLocatorImpl.java
+++ src/main/java/jenkins/branch/WorkspaceLocatorImpl.java
@@ -82,7 +82,6 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
  * @see "JENKINS-2111"
  */
 @Restricted(NoExternalUse.class)
-@Extension(ordinal = -100)
 public class WorkspaceLocatorImpl extends WorkspaceLocator {
 
     private static final Logger LOGGER = Logger.getLogger(WorkspaceLocatorImpl.class.getName());

Before:

$ mvn test -Dtest=WorkspaceLocatorImplTest\#locate

   4.380 [id=39]	INFO	jenkins.InitReactorRunner$1#onAttained: Completed initialization
   4.413 [id=20]	WARNING	jenkins.model.Jenkins#<init>: Exception in onOnline() for the computer listener class jenkins.branch.WorkspaceLocatorImpl$Collector on the built-in node
java.lang.IllegalStateException: Expected 1 instance of jenkins.branch.WorkspaceLocatorImpl but got 0
	at hudson.ExtensionList.lookupSingleton(ExtensionList.java:454)
	at jenkins.branch.WorkspaceLocatorImpl.lockFor(WorkspaceLocatorImpl.java:310)
	at jenkins.branch.WorkspaceLocatorImpl$Collector.onOnline(WorkspaceLocatorImpl.java:631)
	at jenkins.model.Jenkins.<init>(Jenkins.java:1026)
	at hudson.model.Hudson.<init>(Hudson.java:86)
	at org.jvnet.hudson.test.JenkinsRule.newHudson(JenkinsRule.java:697)
	at org.jvnet.hudson.test.JenkinsRule.before(JenkinsRule.java:406)
	at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:601)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.lang.Thread.run(Thread.java:829)

ERROR] Failures: 
[ERROR]   WorkspaceLocatorImplTest.locate:157 expected:<…/branch-api-plugin/target/tmp/j h16047186359448965079/workspace/stuff_dev_flow> but was:<…/branch-api-plugin/target/tmp/j h16047186359448965079/workspace/stuff/dev%2Fflow>
[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

After:

$ mvn test -Dtest=WorkspaceLocatorImplTest\#locate -Djenkins.version=2.430-SNAPSHOT

java.lang.IllegalStateException: Found no instances of jenkins.branch.WorkspaceLocatorImpl registered (possible annotation processor issue); try using `mvn clean test -Dtest=…` rather than an IDE test runner

Copy link
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/label ready-for-merge


This PR is now ready for merge. We will merge it after ~24 hours if there is no negative feedback.
Please see the merge process documentation for more information about the merge process.
Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Oct 29, 2023
@NotMyFault NotMyFault added the skip-changelog Should not be shown in the changelog label Oct 29, 2023
@NotMyFault NotMyFault merged commit 36de7a5 into jenkinsci:master Oct 30, 2023
16 checks passed
@jglick jglick deleted the ExtensionList.lookupSingleton branch October 30, 2023 14:11
flabrie pushed a commit to flabrie/jenkins that referenced this pull request Oct 30, 2023
* master: (72 commits)
  [JENKINS-72189] fix drag&drop handle for existing repeatables (jenkinsci#8613)
  [JENKINS-72222] Fix inconsistent wording between login page and security configuration (jenkinsci#8633)
  More helpful error message for `ExtensionList.lookupSingleton` (jenkinsci#8646)
  Turkish localization fixes for build page (jenkinsci#8651)
  Update dependabot branch for LTS 2.426.x (jenkinsci#8659)
  Update dependency node to v20.9.0 (jenkinsci#8656)
  Update dependency sass to v1.69.5 (jenkinsci#8657)
  Bump org.jenkins-ci.main:jenkins-test-harness from 2096.vcfd8fa_a_67f86 to 2099.vc95b_86578f37 (jenkinsci#8653)
  Bump org.jenkins-ci.main:remoting from 3190.va_7870fc137d9 to 3192.v713e3b_039fb_e (jenkinsci#8654)
  Bump org.jenkins-ci.plugins:credentials from 1304.v5ec13eecef46 to 1307.v3757c78f17c3 (jenkinsci#8655)
  Bump commons-io:commons-io from 2.14.0 to 2.15.0 (jenkinsci#8647)
  Update Yarn to v4 (jenkinsci#8641)
  Bump org.jenkins-ci.plugins:credentials from 1293.vff276f713473 to 1304.v5ec13eecef46 (jenkinsci#8650)
  Bump org.jenkins-ci.main:remoting from 3186.vc3b_7249b_87eb_ to 3190.va_7870fc137d9 (jenkinsci#8649)
  Fix issues with help texts under security configuration (jenkinsci#8630)
  Turkish localization fixes for login and users management pages (jenkinsci#8631)
  Bump com.github.eirslett:frontend-maven-plugin from 1.14.0 to 1.14.2 (jenkinsci#8648)
  Bump org.jenkins-ci.main:remoting from 3181.v78543a_987053 to 3186.vc3b_7249b_87eb_ (jenkinsci#8643)
  Bump org.jenkins-ci.main:jenkins-test-harness from 2090.v6d1706e434a_b_ to 2096.vcfd8fa_a_67f86 (jenkinsci#8642)
  [maven-release-plugin] prepare for next development iteration
  ...

# Conflicts:
#	core/src/main/resources/lib/form/repeatable.jelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog
Projects
None yet
4 participants