changeset 973:0a31f12174ca Indore-2017.1.x

TW-50245 catch errors during GetMethod creation
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Wed, 12 Jul 2017 12:39:40 +0200
parents c5dc2c802e4b
children 81dc5c6fdb25 0c6b0b5f68ea
files mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java	Thu Jun 22 12:54:00 2017 +0200
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java	Wed Jul 12 12:39:40 2017 +0200
@@ -97,9 +97,10 @@
     }
 
     HttpClient client = HttpUtil.createHttpClient(30);
-    GetMethod get = new GetMethod(capabilitiesUrl);
+    GetMethod get = null;
 
     try {
+      get = new GetMethod(capabilitiesUrl);
       if (credentials != null) {
         URL url = new URL(fetchUrl);
         HttpState state = new HttpState();
@@ -129,7 +130,8 @@
     } catch (Exception e) {
       Loggers.VCS.debug("Got error while sending HTTP request to " + capabilitiesUrl, e);
     } finally {
-      get.releaseConnection();
+      if (get != null)
+        get.releaseConnection();
     }
 
     return false;