Skip to content

[JENKINS-48638] Simplified/clarified Jenkins.getInstance #22476

Closed

Description

@jenkins-infra-bot

JENKINS-34857 tracks an abortive attempt to make Jenkins.getInstance throw IllegalStateException as it is documented to do. While fixes like JENKINS-48543 could make that possible, it is safer and more straightforward to have one nondeprecated method which is @​CheckForNull (but rarely used) and one nondeprecated method which is @​Nonnull (and recommended for most callers).


Originally reported by jglick, imported from: Simplified/clarified Jenkins.getInstance
  • assignee: jglick
  • status: Resolved
  • priority: Major
  • component(s): core
  • label(s): api
  • resolution: Fixed
  • resolved: 2017-12-22T17:19:57+00:00
  • votes: 0
  • watchers: 2
  • imported: 2025-11-24
Raw content of original issue

JENKINS-34857 tracks an abortive attempt to make Jenkins.getInstance throw IllegalStateException as it is documented to do. While fixes like JENKINS-48543 could make that possible, it is safer and more straightforward to have one nondeprecated method which is @CheckForNull (but rarely used) and one nondeprecated method which is @Nonnull (and recommended for most callers).

Activity

  1. jenkins-infra-bot commented on Dec 19, 2017

    @jenkins-infra-bot
    Author
    • Remote link associated with this issue:

  2. jenkins-infra-bot commented on Dec 22, 2017

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original comment:

      Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/model/Hudson.java core/src/main/java/jenkins/model/Jenkins.java core/src/main/resources/META-INF/upgrade/Hudson.hint core/src/main/resources/META-INF/upgrade/Jenkins.hint http://jenkins-ci.org/commit/jenkins/001a33c747feb437a1bf5f0349b6988f517ec9a8 Log: JENKINS-48638 Deprecate Jenkins.getInstance in favor of (usually) get (#3195)

      • Deprecate Jenkins.getInstance in favor of (usually) getActiveInstance.
      • Introduced get() as a concise non-null accessor.
      • May as well suggest rewrites of getActiveInstance too.

    Code changed in jenkins
    User: Jesse Glick
    Path:
    core/src/main/java/hudson/model/Hudson.java
    core/src/main/java/jenkins/model/Jenkins.java
    core/src/main/resources/META-INF/upgrade/Hudson.hint
    core/src/main/resources/META-INF/upgrade/Jenkins.hint
    http://jenkins-ci.org/commit/jenkins/001a33c747feb437a1bf5f0349b6988f517ec9a8
    Log:
    JENKINS-48638 Deprecate Jenkins.getInstance in favor of (usually) get (#3195)

    • Deprecate Jenkins.getInstance in favor of (usually) getActiveInstance.
    • Introduced get() as a concise non-null accessor.
    • May as well suggest rewrites of getActiveInstance too.
  3. jenkins-infra-bot commented on Dec 22, 2017

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      Merged toward 2.98.

    Merged toward 2.98.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions