diff --git a/src/main/java/hudson/scm/SubversionSCM.java b/src/main/java/hudson/scm/SubversionSCM.java index 65079927..d5dc31f7 100755 --- a/src/main/java/hudson/scm/SubversionSCM.java +++ b/src/main/java/hudson/scm/SubversionSCM.java @@ -3260,10 +3260,11 @@ public FormValidation checkCredentialsId(/* TODO unused, delete */StaplerRequest return FormValidation.warning("The repository URL is parameterized, connection check skipped"); } + SVNRepository repo = null; try { SVNURL repoURL = SVNURL.parseURIEncoded(remote); StandardCredentials credentials = lookupCredentials(context, value, repoURL); - SVNRepository repo = descriptor().getRepository(context, repoURL, credentials, Collections.emptyMap(), null); + repo = descriptor().getRepository(context, repoURL, credentials, Collections.emptyMap(), null); String repoRoot = repo.getRepositoryRoot(true).toDecodedString(); String repoPath = repo.getLocation().toDecodedString().substring(repoRoot.length()); SVNPath path = new SVNPath(repoPath, true, true); @@ -3274,6 +3275,12 @@ public FormValidation checkCredentialsId(/* TODO unused, delete */StaplerRequest } catch (SVNException e) { LOGGER.log(Level.SEVERE, e.getErrorMessage().getMessage()); return FormValidation.error("Unable to access the repository"); + } finally { + /* TODO: Quick and dirty fix (best to make SVNRepository implement AutoCloseable and remove this method as + jenkins.scm.impl.subversion.SubversionSCMSource.DescriptorImpl.doCheckCredentialsId seems to be doing the exact same thing + */ + if (repo != null) + repo.closeSession(); } return FormValidation.ok(); }