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

[JENKINS-48985] - Better diagnostics for Old Data Monitor null safety #3240

Conversation

oleg-nenashev
Copy link
Member

See JENKINS-48985. It does not fix the issue at all, but it may help with diagnostics of such cases.

Proposed changelog entries

If required (not sure):

  • rfe: Improve diagnostics of missing Old Data Administrative Monitor
  • ...

Submitter checklist

  • JIRA issue is well described
  • Changelog entry appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    * Use the Internal: prefix if the change has no user-visible impact (API, test frameworks, etc.)
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

@oleg-nenashev
Copy link
Member Author

@reviewbybees

@ghost
Copy link

ghost commented Jan 17, 2018

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

core/src/main/java/hudson/diagnosis/OldDataMonitor.java Outdated Show resolved Hide resolved
@@ -116,11 +116,11 @@ public final String getSearchUrl() {
* Mark this monitor as disabled, to prevent this from showing up in the UI.
*/
public void disable(boolean value) throws IOException {
AbstractCIBase hudson = Jenkins.getInstance();
Set<String> set = hudson.disabledAdministrativeMonitors;
AbstractCIBase jenkins = Jenkins.get();
Copy link
Member

Choose a reason for hiding this comment

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

just Jenkins

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. "disabledAdministrativeMonitors" below is a package-scope method, so you need a class from a proper scope to access it. Didn't want to refactor too much

Copy link
Member

Choose a reason for hiding this comment

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

OK, though you could make it @Restricted(NoExternalUse.class) public.

Maybe worth a comment to the effect that this is bypassing package access.

@@ -131,7 +131,7 @@ public void disable(boolean value) throws IOException {
* he wants to ignore.
*/
public boolean isEnabled() {
return !((AbstractCIBase)Jenkins.getInstance()).disabledAdministrativeMonitors.contains(id);
Copy link
Member

Choose a reason for hiding this comment

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

Why the cast?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because disabledAdministrativeMonitors is a package-scoped object. It is not visible from the parent class in another package. Weird, but I do not want to refactor it right now

*/
@CheckForNull
Copy link
Member

Choose a reason for hiding this comment

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

Fine but as above you do not need this method to look up a singleton.

@oleg-nenashev oleg-nenashev self-assigned this Jan 28, 2018
@oleg-nenashev oleg-nenashev added the work-in-progress The PR is under active development, not ready to the final review label Jan 28, 2018
@oleg-nenashev oleg-nenashev removed the work-in-progress The PR is under active development, not ready to the final review label Jan 28, 2019
@oleg-nenashev
Copy link
Member Author

@jglick ready for re-review

@oleg-nenashev oleg-nenashev added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jan 28, 2019
@oleg-nenashev
Copy link
Member Author

@jenkinsci/core I would like to land it if you are fine with it

Copy link
Contributor

@jeffret-b jeffret-b left a comment

Choose a reason for hiding this comment

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

It seems like an improvement, though it's hard to just just how it will help.

@@ -116,11 +116,11 @@ public final String getSearchUrl() {
* Mark this monitor as disabled, to prevent this from showing up in the UI.
*/
public void disable(boolean value) throws IOException {
AbstractCIBase hudson = Jenkins.getInstance();
Set<String> set = hudson.disabledAdministrativeMonitors;
AbstractCIBase jenkins = Jenkins.get();
Copy link
Member

Choose a reason for hiding this comment

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

OK, though you could make it @Restricted(NoExternalUse.class) public.

Maybe worth a comment to the effect that this is bypassing package access.

@oleg-nenashev
Copy link
Member Author

@jglick I have created https://issues.jenkins-ci.org/browse/JENKINS-55829 as a follow-up so that somebody can address it.

@oleg-nenashev oleg-nenashev merged commit d8c82d9 into jenkinsci:master Jan 29, 2019
@oleg-nenashev oleg-nenashev deleted the feature/JENKINS-48985-ODM-null-safety branch January 29, 2019 08:50
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
Projects
None yet
3 participants