From 4140c85326fbc3996405577fb184f1fe44f97c39 Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 4 Apr 2018 11:01:43 +0200 Subject: [PATCH 1/6] close tag as intended --- .../resources/hudson/scm/browsers/FishEyeSVN/help-url_de.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/hudson/scm/browsers/FishEyeSVN/help-url_de.html b/src/main/resources/hudson/scm/browsers/FishEyeSVN/help-url_de.html index 1019b2e03..85f55f16e 100644 --- a/src/main/resources/hudson/scm/browsers/FishEyeSVN/help-url_de.html +++ b/src/main/resources/hudson/scm/browsers/FishEyeSVN/help-url_de.html @@ -1,4 +1,4 @@
Geben Sie die FishEye-URL des Moduls an, z.B. - http://fisheye6.cenqua.com/browse/ant/. + http://fisheye6.cenqua.com/browse/ant/.
\ No newline at end of file From a8ec5bf61c63205afc13152440989118bfbbccae Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 4 Apr 2018 11:02:58 +0200 Subject: [PATCH 2/6] removed unnecessary unboxing and simplified JUnit expressions --- src/test/java/hudson/scm/SubversionSCMTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/hudson/scm/SubversionSCMTest.java b/src/test/java/hudson/scm/SubversionSCMTest.java index 7695d05ba..4dd32b21f 100644 --- a/src/test/java/hudson/scm/SubversionSCMTest.java +++ b/src/test/java/hudson/scm/SubversionSCMTest.java @@ -250,7 +250,7 @@ public void moduleLocationRevisions() throws Exception { m = new SubversionSCM.ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@HEAD", null); r = m.getRevision(null); assertTrue(r.isValid()); - assertTrue(r == SVNRevision.HEAD); + assertSame(r, SVNRevision.HEAD); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", m.getURL()); m = new SubversionSCM.ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@FAKE", null); @@ -500,7 +500,7 @@ public Long getActualRevision(FreeStyleBuild b, String url) throws Exception { throw new Exception("No revision found!"); } - return revisionState.revisions.get(url).longValue(); + return revisionState.revisions.get(url); } /** @@ -836,7 +836,7 @@ public void testQuietCheckout() throws Exception { List logsQuiet = bQuiet.getLog(LOG_LIMIT); // This line in log should end with --quiet assertTrue(logsQuiet.get(4).endsWith("--quiet")); - assertTrue(logsQuiet.get(5).equals("At revision 1")); + assertEquals("At revision 1", logsQuiet.get(5)); local.setQuietOperation(false); FreeStyleBuild bVerbose = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserIdCause()).get()); @@ -844,7 +844,7 @@ public void testQuietCheckout() throws Exception { // This line in log should NOT end with --quiet assertFalse(logsVerbose.get(4).endsWith("--quiet")); assertTrue(logsVerbose.get(5).endsWith("readme.txt")); - assertTrue(logsVerbose.get(6).equals("At revision 1")); + assertEquals("At revision 1", logsVerbose.get(6)); } /** From d60a9b146c5b647fccbc39e32d6c3332ec83c90b Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 4 Apr 2018 12:11:09 +0200 Subject: [PATCH 3/6] replaced iteartion with bulk operation and removed redundant Typedefinition --- .../impl/subversion/SubversionSCMSourceTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/java/jenkins/scm/impl/subversion/SubversionSCMSourceTest.java b/src/test/java/jenkins/scm/impl/subversion/SubversionSCMSourceTest.java index 2efdfd640..1c04f3e8e 100644 --- a/src/test/java/jenkins/scm/impl/subversion/SubversionSCMSourceTest.java +++ b/src/test/java/jenkins/scm/impl/subversion/SubversionSCMSourceTest.java @@ -59,15 +59,15 @@ public void isMatch() throws Exception { @Test public void splitCludes() throws Exception { assertThat(SubversionSCMSource.splitCludes("trunk"), - is((SortedSet) new TreeSet(Arrays.asList("trunk")))); + is((SortedSet) new TreeSet<>(Arrays.asList("trunk")))); assertThat(SubversionSCMSource.splitCludes("trunk,branches/*"), - is((SortedSet) new TreeSet(Arrays.asList("trunk", "branches/*")))); + is((SortedSet) new TreeSet<>(Arrays.asList("trunk", "branches/*")))); assertThat(SubversionSCMSource.splitCludes("trunk, branches/*"), - is((SortedSet) new TreeSet(Arrays.asList("trunk", "branches/*")))); + is((SortedSet) new TreeSet<>(Arrays.asList("trunk", "branches/*")))); assertThat(SubversionSCMSource.splitCludes("trunk , , branches/*"), - is((SortedSet) new TreeSet(Arrays.asList("trunk", "branches/*")))); + is((SortedSet) new TreeSet<>(Arrays.asList("trunk", "branches/*")))); assertThat(SubversionSCMSource.splitCludes("trunk , , branches/* , tags/* "), - is((SortedSet) new TreeSet(Arrays.asList("trunk", "branches/*", "tags/*")))); + is((SortedSet) new TreeSet<>(Arrays.asList("trunk", "branches/*", "tags/*")))); } private static List list(String... values) { @@ -75,10 +75,8 @@ private static List list(String... values) { } private static SortedSet> pathSet(List... paths) { - SortedSet> result = new TreeSet>(new SubversionSCMSource.StringListComparator()); - for (List path : paths) { - result.add(path); - } + SortedSet> result = new TreeSet<>(new SubversionSCMSource.StringListComparator()); + result.addAll(Arrays.asList(paths)); return result; } From afc2d569d3fdfb0f1f694063cbb08e5cbb39e2a4 Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 4 Apr 2018 12:11:59 +0200 Subject: [PATCH 4/6] use try with resources --- .../hudson/scm/AbstractSubversionTest.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/test/java/hudson/scm/AbstractSubversionTest.java b/src/test/java/hudson/scm/AbstractSubversionTest.java index 3033bf109..b349c9f25 100644 --- a/src/test/java/hudson/scm/AbstractSubversionTest.java +++ b/src/test/java/hudson/scm/AbstractSubversionTest.java @@ -72,11 +72,8 @@ public Proc runSvnServe(URL zip) throws Exception { public static Proc runSvnServe(TemporaryFolder tmp, URL zip) throws Exception { File target = tmp.newFolder(); - InputStream is = zip.openStream(); - try { + try (InputStream is = zip.openStream()) { new FilePath(target).unzipFrom(is); - } finally { - is.close(); } return runSvnServe(target); } @@ -91,23 +88,17 @@ public static Proc runSvnServe(File repo) throws Exception { // If there is an already existing svnserve running on the machine // We need to fail the build. We could change this to if the port is in use, listen to different port - Socket s = null; ServerSocket serverSocket = null; int port = 3690; // Default svnserve port is 3690. - try { - s = new Socket("localhost", 3690); - // If it gets this far, that means that it is able to send/receive information. - // Since the default svnserve port is currently in use, fail the build. - System.err.println("Port 3690 is currently in use. Using a random port."); - serverSocket = new ServerSocket(0); - port = serverSocket.getLocalPort(); - serverSocket.close(); + try (Socket s = new Socket("localhost", 3690)) { + // If it gets this far, that means that it is able to send/receive information. + // Since the default svnserve port is currently in use, fail the build. + System.err.println("Port 3690 is currently in use. Using a random port."); + serverSocket = new ServerSocket(0); + port = serverSocket.getLocalPort(); + serverSocket.close(); } catch (IOException e) { - // Port is not in use - } finally { - if (s != null) { - s.close(); - } + // Port is not in use } return launcher.launch().cmds( From 9f9e5b9142f33fd8c76e4e579dbb342b83d63a5d Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 4 Apr 2018 12:19:09 +0200 Subject: [PATCH 5/6] removed redundant type definitions and introduced lambdas --- .../hudson/scm/CredentialsExternalsTest.java | 2 +- .../java/hudson/scm/DefaultSVNLogFilterTest.java | 16 +++++++--------- .../hudson/scm/SubversionChangeLogSetTest.java | 4 ++-- .../scm/SubversionRepositoryStatusTest.java | 6 +----- .../scm/SubversionSCMChangeLogEntryTest.java | 2 +- src/test/java/hudson/scm/SubversionSCMTest.java | 16 +++++++--------- .../java/hudson/scm/SubversionSCMUnitTest.java | 8 ++++---- ...istSubversionTagsParameterDefinitionTest.java | 7 +------ .../SimpleSVNDirEntryHandlerTest.java | 4 +--- .../subversion/SubversionSampleRepoRule.java | 2 +- 10 files changed, 26 insertions(+), 41 deletions(-) diff --git a/src/test/java/hudson/scm/CredentialsExternalsTest.java b/src/test/java/hudson/scm/CredentialsExternalsTest.java index 5b7d01af9..03d5afc4b 100644 --- a/src/test/java/hudson/scm/CredentialsExternalsTest.java +++ b/src/test/java/hudson/scm/CredentialsExternalsTest.java @@ -128,7 +128,7 @@ public void smokes() throws Exception { b = r.buildAndAssertSuccess(p); assertEquals("mainrev", b.getWorkspace().child("file").readToString()); assertEquals("extrev", b.getWorkspace().child("ext/file").readToString()); - Set messages = new TreeSet(); + Set messages = new TreeSet<>(); for (ChangeLogSet.Entry entry : b.getChangeSet()) { messages.add(entry.getMsg()); } diff --git a/src/test/java/hudson/scm/DefaultSVNLogFilterTest.java b/src/test/java/hudson/scm/DefaultSVNLogFilterTest.java index 7f7824e44..39a1fe16d 100644 --- a/src/test/java/hudson/scm/DefaultSVNLogFilterTest.java +++ b/src/test/java/hudson/scm/DefaultSVNLogFilterTest.java @@ -41,12 +41,10 @@ public void tearDown() throws Exception { } private List doFilter(final SVNLogFilter logFilter) throws SVNException { - final List log = new ArrayList(); - ISVNLogEntryHandler logGatherer = new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { - if (logFilter.isIncluded(logEntry)) { - log.add(logEntry); - } + final List log = new ArrayList<>(); + ISVNLogEntryHandler logGatherer = logEntry -> { + if (logFilter.isIncluded(logEntry)) { + log.add(logEntry); } }; svnRepo.log(empty, 1, 5, true, false, logGatherer); @@ -54,7 +52,7 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { } private static Pattern [] compile(String ... regexes) { - List patterns = new ArrayList(); + List patterns = new ArrayList<>(); for (String re : regexes) { patterns.add(Pattern.compile(re)); } @@ -120,7 +118,7 @@ public void bothIncludesAndExcludes() throws Exception { @Test public void excludedUsers() throws Exception { - Set users = new HashSet(); + Set users = new HashSet<>(); users.add("brent"); DefaultSVNLogFilter filter = new DefaultSVNLogFilter(noPatterns, noPatterns, users, null, noPatterns, false); @@ -172,7 +170,7 @@ public void globalExclusionRevprop() throws Exception { SVNProperties p = new SVNProperties(); p.put("ignoreme", "*"); - Map paths = new HashMap(); + Map paths = new HashMap<>(); paths.put("/foo", new SVNLogEntryPath("/foo", SVNLogEntryPath.TYPE_MODIFIED, null, -1)); SVNLogEntry e = new SVNLogEntry(paths, 1234L, p, false); diff --git a/src/test/java/hudson/scm/SubversionChangeLogSetTest.java b/src/test/java/hudson/scm/SubversionChangeLogSetTest.java index c9fd8905a..862e7cf1a 100644 --- a/src/test/java/hudson/scm/SubversionChangeLogSetTest.java +++ b/src/test/java/hudson/scm/SubversionChangeLogSetTest.java @@ -43,7 +43,7 @@ public class SubversionChangeLogSetTest { @Test public void testRemoveDuplicateEntries() throws Exception{ //One duplicated entry. 7 unique, 8 total entries. - List items = new ArrayList(); + List items = new ArrayList<>(); items.add(buildChangeLogEntry(1, "Test msg")); items.add(buildChangeLogEntry(2, "Test msg")); items.add(buildChangeLogEntry(1, "Test msg")); @@ -57,7 +57,7 @@ public void testRemoveDuplicateEntries() throws Exception{ Assert.assertEquals(resultItems.size(), 7); //No duplicated entries. Total 7 - items = new ArrayList(); + items = new ArrayList<>(); items.add(buildChangeLogEntry(1, "Test msg")); items.add(buildChangeLogEntry(2, "Test msg")); items.add(buildChangeLogEntry(3, "Test msg")); diff --git a/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java b/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java index f6b7462a7..4c2ebf4b9 100644 --- a/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java +++ b/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java @@ -41,11 +41,7 @@ public void shouldIgnoreDisabledJobs() throws ServletException, IOException { final AbstractProject project = mock(AbstractProject.class); when(project.isDisabled()).thenReturn(true); - JobProvider jobProvider = new JobProvider() { - public List getAllJobs() { - return Collections.singletonList(project); - } - }; + JobProvider jobProvider = () -> Collections.singletonList(project); listener.setJobProvider(jobProvider); diff --git a/src/test/java/hudson/scm/SubversionSCMChangeLogEntryTest.java b/src/test/java/hudson/scm/SubversionSCMChangeLogEntryTest.java index 19574134b..a4fee86d7 100644 --- a/src/test/java/hudson/scm/SubversionSCMChangeLogEntryTest.java +++ b/src/test/java/hudson/scm/SubversionSCMChangeLogEntryTest.java @@ -8,7 +8,7 @@ public class SubversionSCMChangeLogEntryTest { - private SubversionChangeLogSet.LogEntry entry = SubversionChangeLogUtil.buildChangeLogEntry(99, "Dummy");; + private SubversionChangeLogSet.LogEntry entry = SubversionChangeLogUtil.buildChangeLogEntry(99, "Dummy"); @Test public void testRemoveIgnoredDirPropChangesNotRemoving() throws Exception { diff --git a/src/test/java/hudson/scm/SubversionSCMTest.java b/src/test/java/hudson/scm/SubversionSCMTest.java index 4dd32b21f..82162322c 100644 --- a/src/test/java/hudson/scm/SubversionSCMTest.java +++ b/src/test/java/hudson/scm/SubversionSCMTest.java @@ -114,11 +114,9 @@ public void taggingPermission() throws Exception { r.assertBuildStatus(Result.SUCCESS,b); final SubversionTagAction action = b.getAction(SubversionTagAction.class); - r.executeOnServer(new Callable() { - public Object call() throws Exception { - assertFalse("Shouldn't be accessible to anonymous user",b.hasPermission(action.getPermission())); - return null; - } + r.executeOnServer(() -> { + assertFalse("Shouldn't be accessible to anonymous user",b.hasPermission(action.getPermission())); + return null; }); JenkinsRule.WebClient wc = r.createWebClient(); @@ -702,7 +700,7 @@ public void configRoundtrip2() throws Exception { public void checkEmptyRemoteRemoved() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); - List locs = new ArrayList(); + List locs = new ArrayList<>(); locs.add(new ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/testSubversionExclusion", "c")); locs.add(new ModuleLocation("", "d")); locs.add(new ModuleLocation(" ", "e")); @@ -995,7 +993,7 @@ private void verifyChangelogFilter(boolean shouldFilterLog) throws Exception, } boolean result = ignored && included; - assertTrue("Changelog included or excluded entries it shouldn't have.", shouldFilterLog? result : !result); + assertEquals("Changelog included or excluded entries it shouldn't have.", shouldFilterLog, result); } /** @@ -1137,7 +1135,7 @@ private void createCommit(SubversionSCM scm, String... paths) throws Exception { FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null); - List added = new ArrayList(); + List added = new ArrayList<>(); for (String path : paths) { FilePath newFile = b.getWorkspace().child(path); added.add(new File(newFile.getRemote())); @@ -1238,7 +1236,7 @@ public void infiniteLoop() throws Exception { r.jenkins.getDescriptorByType(SubversionSCM.DescriptorImpl.class).postCredential(null,repo.toDecodedString(),"guest","",null,new PrintWriter(System.out)); // emulate the call flow where the credential fails - List attempted = new ArrayList(); + List attempted = new ArrayList<>(); SVNAuthentication a = m.getFirstAuthentication(kind, realm, repo); assertNotNull(a); attempted.add(a); diff --git a/src/test/java/hudson/scm/SubversionSCMUnitTest.java b/src/test/java/hudson/scm/SubversionSCMUnitTest.java index da9459657..5b9289740 100644 --- a/src/test/java/hudson/scm/SubversionSCMUnitTest.java +++ b/src/test/java/hudson/scm/SubversionSCMUnitTest.java @@ -59,13 +59,13 @@ public void shouldSetEnvironmentVariablesWithSingleSvnModule() throws IOExceptio ModuleLocation[] singleLocation = new ModuleLocation[] {new ModuleLocation("/remotepath", "")}; when(scm.getLocations(any(EnvVars.class), any(AbstractBuild.class))).thenReturn(singleLocation); - Map revisions = new HashMap(); + Map revisions = new HashMap<>(); revisions.put("/remotepath", 4711L); when(scm.parseSvnRevisionFile(any(AbstractBuild.class))).thenReturn(revisions); // WHEN envVars are build AbstractBuild build = mock(AbstractBuild.class); - Map envVars = new HashMap(); + Map envVars = new HashMap<>(); scm.buildEnvVars(build, envVars); // THEN: we have the (legacy) SVN_URL and SVN_REVISION vars @@ -88,14 +88,14 @@ public void shouldSetEnvironmentVariablesWithMultipleSvnModules() throws IOExcep new ModuleLocation("/remotepath2", "")}; when(scm.getLocations(any(EnvVars.class), any(AbstractBuild.class))).thenReturn(locations); - Map revisions = new HashMap(); + Map revisions = new HashMap<>(); revisions.put("/remotepath1", 4711L); revisions.put("/remotepath2", 42L); when(scm.parseSvnRevisionFile(any(AbstractBuild.class))).thenReturn(revisions); // WHEN envVars are build AbstractBuild build = mock(AbstractBuild.class); - Map envVars = new HashMap(); + Map envVars = new HashMap<>(); scm.buildEnvVars(build, envVars); // THEN: we have the SVN_URL_n and SVN_REVISION_n vars diff --git a/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterDefinitionTest.java b/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterDefinitionTest.java index 0275084b6..b92b441df 100644 --- a/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterDefinitionTest.java +++ b/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterDefinitionTest.java @@ -86,12 +86,7 @@ private void dumpRepositoryContents() throws SVNException { System.out.println("Repository contents:"); SVNURL repoURL = SVNURL.parseURIEncoded( "svn://localhost/"); SVNLogClient logClient = new SVNLogClient((ISVNAuthenticationManager)null, null); - logClient.doList(repoURL, SVNRevision.HEAD, SVNRevision.HEAD, false, true, new ISVNDirEntryHandler() { - @Override - public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException { - System.out.println(dirEntry.getRelativePath()); - } - }); + logClient.doList(repoURL, SVNRevision.HEAD, SVNRevision.HEAD, false, true, dirEntry -> System.out.println(dirEntry.getRelativePath())); } @Issue("SECURITY-303") diff --git a/src/test/java/hudson/scm/listtagsparameter/SimpleSVNDirEntryHandlerTest.java b/src/test/java/hudson/scm/listtagsparameter/SimpleSVNDirEntryHandlerTest.java index be78ac301..78a636f1c 100644 --- a/src/test/java/hudson/scm/listtagsparameter/SimpleSVNDirEntryHandlerTest.java +++ b/src/test/java/hudson/scm/listtagsparameter/SimpleSVNDirEntryHandlerTest.java @@ -98,9 +98,7 @@ private void addEntries(SimpleSVNDirEntryHandler handler) { handler.handleDirEntry(getEntry("2011-11-01", "trunk/b")); handler.handleDirEntry(getEntry("2011-10-01", "trunk/x")); handler.handleDirEntry(getEntry("2011-09-01", "trunk/c")); - } catch (ParseException e) { - Assert.fail(e.toString()); - } catch (SVNException e) { + } catch (ParseException | SVNException e) { Assert.fail(e.toString()); } } diff --git a/src/test/java/jenkins/scm/impl/subversion/SubversionSampleRepoRule.java b/src/test/java/jenkins/scm/impl/subversion/SubversionSampleRepoRule.java index 698c30c7b..91df77af1 100644 --- a/src/test/java/jenkins/scm/impl/subversion/SubversionSampleRepoRule.java +++ b/src/test/java/jenkins/scm/impl/subversion/SubversionSampleRepoRule.java @@ -118,7 +118,7 @@ private void checkForSvnCLI() throws Exception { @Deprecated public void svn(String... cmds) throws Exception { checkForSvnCLI(); - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("svn"); args.addAll(Arrays.asList(cmds)); run(false, wc, args.toArray(new String[args.size()])); From 17545410200663458d982a70a25ad2f3a60fd245 Mon Sep 17 00:00:00 2001 From: Stefan Spieker Date: Wed, 2 Oct 2019 23:05:48 +0200 Subject: [PATCH 6/6] replaced some deprecated calls with newer alternative --- .../java/hudson/scm/SubversionChangeLogBuilder.java | 3 +-- src/main/java/hudson/scm/SubversionSCM.java | 6 +++--- src/main/java/hudson/scm/browsers/Sventon.java | 2 +- src/main/java/hudson/scm/browsers/Sventon2.java | 2 +- .../java/hudson/scm/subversion/UpdateUpdater.java | 3 +-- .../scm/impl/subversion/SubversionSCMSource.java | 4 ++-- .../hudson/scm/SubversionRepositoryStatusTest.java | 11 ++--------- src/test/java/hudson/scm/SubversionSCMUnitTest.java | 4 ++-- src/test/java/hudson/scm/SvnHelperTest.java | 4 ++-- .../ListSubversionTagsParameterValueTest.java | 6 +++--- 10 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/main/java/hudson/scm/SubversionChangeLogBuilder.java b/src/main/java/hudson/scm/SubversionChangeLogBuilder.java index a22cee281..f23af3429 100644 --- a/src/main/java/hudson/scm/SubversionChangeLogBuilder.java +++ b/src/main/java/hudson/scm/SubversionChangeLogBuilder.java @@ -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; @@ -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; diff --git a/src/main/java/hudson/scm/SubversionSCM.java b/src/main/java/hudson/scm/SubversionSCM.java index 8b859ab72..a5743f4d6 100755 --- a/src/main/java/hudson/scm/SubversionSCM.java +++ b/src/main/java/hudson/scm/SubversionSCM.java @@ -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(); } @@ -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(); } @@ -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(); } diff --git a/src/main/java/hudson/scm/browsers/Sventon.java b/src/main/java/hudson/scm/browsers/Sventon.java index a0b42f698..958d0201b 100644 --- a/src/main/java/hudson/scm/browsers/Sventon.java +++ b/src/main/java/hudson/scm/browsers/Sventon.java @@ -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(); } diff --git a/src/main/java/hudson/scm/browsers/Sventon2.java b/src/main/java/hudson/scm/browsers/Sventon2.java index 4a1bd94d4..f2b6861bb 100644 --- a/src/main/java/hudson/scm/browsers/Sventon2.java +++ b/src/main/java/hudson/scm/browsers/Sventon2.java @@ -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(); } diff --git a/src/main/java/hudson/scm/subversion/UpdateUpdater.java b/src/main/java/hudson/scm/subversion/UpdateUpdater.java index da502169a..a65f7e4d2 100755 --- a/src/main/java/hudson/scm/subversion/UpdateUpdater.java +++ b/src/main/java/hudson/scm/subversion/UpdateUpdater.java @@ -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; @@ -200,7 +199,7 @@ public List 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()); } diff --git a/src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java b/src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java index ce6bcc995..c5244e372 100644 --- a/src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java +++ b/src/main/java/jenkins/scm/impl/subversion/SubversionSCMSource.java @@ -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); } @@ -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(); } diff --git a/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java b/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java index 4c2ebf4b9..ab5635122 100644 --- a/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java +++ b/src/test/java/hudson/scm/SubversionRepositoryStatusTest.java @@ -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 @@ -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(); diff --git a/src/test/java/hudson/scm/SubversionSCMUnitTest.java b/src/test/java/hudson/scm/SubversionSCMUnitTest.java index 5b9289740..a3e281124 100644 --- a/src/test/java/hudson/scm/SubversionSCMUnitTest.java +++ b/src/test/java/hudson/scm/SubversionSCMUnitTest.java @@ -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}. @@ -32,7 +32,7 @@ public class SubversionSCMUnitTest { @Test - @Bug(12113) + @Issue("JENKINS-12113") public void testLocalDirectoryIsExpandedWithEnvVars() { FilePath root = new FilePath((VirtualChannel)null, "root"); diff --git a/src/test/java/hudson/scm/SvnHelperTest.java b/src/test/java/hudson/scm/SvnHelperTest.java index b53d030e6..a5cdb28c7 100644 --- a/src/test/java/hudson/scm/SvnHelperTest.java +++ b/src/test/java/hudson/scm/SvnHelperTest.java @@ -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}. @@ -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"); diff --git a/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterValueTest.java b/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterValueTest.java index 7e579dfb1..a28546414 100644 --- a/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterValueTest.java +++ b/src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterValueTest.java @@ -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; @@ -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, @@ -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,