From a8f711c1ac1416d437cf5d660bfb10a2494c59a7 Mon Sep 17 00:00:00 2001 From: akruchinin Date: Wed, 13 Nov 2024 19:45:16 +0500 Subject: [PATCH] Fixing an issue, when if you open a task with any defined Subversion configuration, opening a job settigns page will cause the connections opened by this action to hang indefinitely --- src/main/java/hudson/scm/SubversionSCM.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/scm/SubversionSCM.java b/src/main/java/hudson/scm/SubversionSCM.java index eca41c43..491cf81b 100755 --- a/src/main/java/hudson/scm/SubversionSCM.java +++ b/src/main/java/hudson/scm/SubversionSCM.java @@ -3256,10 +3256,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); @@ -3270,6 +3271,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(); }