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

Fixed some deprecated usages #239

Merged
merged 7 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/hudson/scm/SubversionChangeLogBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import hudson.scm.SubversionSCM.ModuleLocation;
import hudson.FilePath;
import hudson.remoting.VirtualChannel;
import hudson.FilePath.FileCallable;
import hudson.model.Run;
import hudson.model.TaskListener;
import org.kohsuke.accmod.Restricted;
Expand Down Expand Up @@ -234,7 +233,7 @@ private static TransformerHandler createTransformerHandler() {

private static final LocatorImpl DUMMY_LOCATOR = new LocatorImpl();

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "MS_SHOULD_BE_FINAL",
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL",
justification = "Debugging environment variable is made editable, so it can be modified through the groovy console.")
public static boolean debug = false;

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/hudson/scm/SubversionSCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -3130,7 +3130,7 @@ public String getDisplayName() {
}

public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String remote) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (context == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel();
}
Expand Down Expand Up @@ -3194,7 +3194,7 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath I
@QueryParameter String remote, @QueryParameter String value) {

// Test the connection only if we may use the credentials (cf. hudson.plugins.git.UserRemoteConfig.DescriptorImpl.doCheckUrl)
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (context == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
Expand Down Expand Up @@ -3417,7 +3417,7 @@ public String getDisplayName() {

public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context,
@QueryParameter String realm) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (context == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/scm/browsers/Sventon.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String getDisplayName() {
public FormValidation doCheckUrl(@AncestorInPath Item project,
@QueryParameter(fixEmpty=true) final String value)
throws IOException, ServletException {
if (project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (project == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
project != null && !project.hasPermission(Item.EXTENDED_READ)) {
return FormValidation.ok();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/scm/browsers/Sventon2.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public String getDisplayName() {
public FormValidation doCheckUrl(@AncestorInPath Item project,
@QueryParameter(fixEmpty=true) final String value)
throws IOException, ServletException {
if (project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (project == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
project != null && !project.hasPermission(Item.EXTENDED_READ)) {
return FormValidation.ok();
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/hudson/scm/subversion/UpdateUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import hudson.Extension;
import hudson.scm.SubversionSCM.External;
import hudson.scm.SubversionSCM.ModuleLocation;
import hudson.scm.SubversionSCM.SvnInfo;
import hudson.triggers.SCMTrigger;
import jenkins.model.Jenkins;
import org.apache.commons.lang.time.FastDateFormat;
Expand Down Expand Up @@ -200,7 +199,7 @@ public List<External> perform() throws IOException, InterruptedException {
}
// trouble-shooting probe for #591
if (errorCode == SVNErrorCode.WC_NOT_LOCKED) {
Jenkins instance = Jenkins.getInstance();
Jenkins instance = Jenkins.getInstanceOrNull();
if (instance != null) {
listener.getLogger().println("Polled jobs are " + instance.getDescriptorByType(SCMTrigger.DescriptorImpl.class).getItemsBeingPolled());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public String getDisplayName() {
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context,
@QueryParameter String remoteBase,
@QueryParameter String credentialsId) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (context == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(credentialsId);
}
Expand Down Expand Up @@ -829,7 +829,7 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context,
public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath Item context, @QueryParameter String remoteBase, @QueryParameter String value) {
// TODO suspiciously similar to SubversionSCM.ModuleLocation.DescriptorImpl.checkCredentialsId; refactor into shared method?
// Test the connection only if we may use the credentials
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
if (context == null && !Jenkins.get().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
Expand Down
11 changes: 2 additions & 9 deletions src/test/java/hudson/scm/SubversionRepositoryStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@
import hudson.model.Job;
import hudson.scm.SubversionRepositoryStatus.JobProvider;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import javax.servlet.ServletException;

import org.junit.Test;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.jvnet.hudson.test.Bug;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.jvnet.hudson.test.Issue;

/**
* @author kutzi
Expand All @@ -33,7 +26,7 @@ public class SubversionRepositoryStatusTest {

@SuppressWarnings("rawtypes")
@Test
@Bug(15794)
@Issue("JENKINS-15794")
public void shouldIgnoreDisabledJobs() throws ServletException, IOException {
SubversionRepositoryStatus.JobTriggerListenerImpl listener = new SubversionRepositoryStatus.JobTriggerListenerImpl();

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/scm/SubversionSCMUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.junit.Assert;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Issue;

/**
* Unit tests for {@link SubversionSCM}.
Expand All @@ -32,7 +32,7 @@
public class SubversionSCMUnitTest {

@Test
@Bug(12113)
@Issue("JENKINS-12113")
public void testLocalDirectoryIsExpandedWithEnvVars() {
FilePath root = new FilePath((VirtualChannel)null, "root");

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/scm/SvnHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import hudson.scm.subversion.SvnHelper;
import org.junit.Assert;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Issue;

/**
* Contains tests for {@link SvnHelper}.
Expand Down Expand Up @@ -66,7 +66,7 @@ public void testGetUrlWithoutRevision_withEndingSlash() {
}

@Test
@Bug(20344)
@Issue("JENKINS-20344")
public void testGetUrlWithoutRevision_withSlashAndSuffix() {
testGetUrlWithoutRevision(URL_PREFIX+"/@HEAD");
testGetUrlWithoutRevision(URL_PREFIX+"//@HEAD");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hudson.scm.listtagsparameter;

import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Issue;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
Expand All @@ -17,7 +17,7 @@ public class ListSubversionTagsParameterValueTest {
* Since we are overriding the equals method, we should write a test unit.
*/
@Test
@Bug(18534)
@Issue("JENKINS-18534")
public void testEquality() {
ListSubversionTagsParameterValue parameterValue = new ListSubversionTagsParameterValue(expectedName,
expectedTag,
Expand Down Expand Up @@ -61,7 +61,7 @@ public void testEquality() {
* Since we are overriding the hashcode method, we should write a test unit.
*/
@Test
@Bug(18534)
@Issue("JENKINS-18534")
public void testHashCode() {
ListSubversionTagsParameterValue parameterValue = new ListSubversionTagsParameterValue(expectedName,
expectedTag,
Expand Down