Skip to content

[JENKINS-23339] Introduce the validated version of Jenkins:getInstance() #23168

Closed

Description

@jenkins-infra-bot

Currently, the jenkins.model.Jenkins::getInstance() method is marked as @​CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.

I propose to...

  1. Add an additional method (e.g. Jenkins::getActiveInstance()), which throws an exception on access errors
  2. Convert all non-checked Jenkins::getInstance() methods

Originally reported by oleg_nenashev, imported from: Introduce the validated version of Jenkins:getInstance()
  • assignee: oleg_nenashev
  • status: Resolved
  • priority: Major
  • component(s): core
  • label(s): api, jenkins
  • resolution: Fixed
  • resolved: 2014-11-07T19:55:57+00:00
  • votes: 0
  • watchers: 3
  • imported: 2025-11-24
Raw content of original issue

Currently, the jenkins.model.Jenkins::getInstance() method is marked as @CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.

I propose to...

  1. Add an additional method (e.g. Jenkins::getActiveInstance()), which throws an exception on access errors
  2. Convert all non-checked Jenkins::getInstance() methods

Activity

  1. jenkins-infra-bot commented on Nov 7, 2014

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

      Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/model/Hudson.java core/src/main/java/jenkins/model/Jenkins.java http://jenkins-ci.org/commit/jenkins/e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7 Log: [FIXED JENKINS-23339] - Introduce the validated Jenkins::getActiveInstance() method

      jenkins.model.Jenkins::getInstance() method is marked as @CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.

      The change also adds annotations to old methods like Hudson::getInstance()

      Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>

    Code changed in jenkins
    User: Oleg Nenashev
    Path:
    core/src/main/java/hudson/model/Hudson.java
    core/src/main/java/jenkins/model/Jenkins.java
    http://jenkins-ci.org/commit/jenkins/e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7
    Log:
    [FIXED JENKINS-23339] - Introduce the validated Jenkins::getActiveInstance() method

    jenkins.model.Jenkins::getInstance() method is marked as @​CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.

    The change also adds annotations to old methods like Hudson::getInstance()

    Signed-off-by: Oleg Nenashev

  2. jenkins-infra-bot commented on Nov 7, 2014

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    core/src/main/java/hudson/model/Hudson.java
    core/src/main/java/jenkins/model/Jenkins.java
    http://jenkins-ci.org/commit/jenkins/bfa557b16af80f8451980452a3dff97643138614
    Log:
    Merge branch 'JENKINS-23339' of github.com:synopsys-arc-oss/jenkins

  3. jenkins-infra-bot commented on Nov 7, 2014

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

      Integrated in jenkins_main_trunk #3802 [FIXED JENKINS-23339] - Introduce the validated Jenkins::getActiveInstance() method (Revision e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7)

      Result = SUCCESS o.v.nenashev : e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7 Files :

      • core/src/main/java/jenkins/model/Jenkins.java
      • core/src/main/java/hudson/model/Hudson.java

    Integrated in jenkins_main_trunk #3802
    [FIXED JENKINS-23339] - Introduce the validated Jenkins::getActiveInstance() method (Revision e6c2e16)

    Result = SUCCESS
    o.v.nenashev : e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7
    Files :

    • core/src/main/java/jenkins/model/Jenkins.java
    • core/src/main/java/hudson/model/Hudson.java
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