Repository: hive Updated Branches: refs/heads/master 7c1f01004 -> f8a671d8c
HIVE-19077: Handle duplicate ptests requests standing in queue at the same time - addendum Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/f8a671d8 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f8a671d8 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f8a671d8 Branch: refs/heads/master Commit: f8a671d8cfe8a26d1d12c51f93207ec92577c796 Parents: 7c1f010 Author: Adam Szita <sz...@cloudera.com> Authored: Wed Apr 11 10:49:24 2018 +0200 Committer: Peter Vary <pv...@cloudera.com> Committed: Wed Apr 11 10:49:24 2018 +0200 ---------------------------------------------------------------------- .../hive/ptest/api/client/JenkinsQueueUtil.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/f8a671d8/testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java ---------------------------------------------------------------------- diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java b/testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java index f973781..f335164 100644 --- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java +++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java @@ -20,6 +20,8 @@ package org.apache.hive.ptest.api.client; import java.io.IOException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; @@ -27,7 +29,9 @@ import org.apache.commons.cli.CommandLine; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.databind.JsonNode; @@ -50,7 +54,6 @@ public class JenkinsQueueUtil { private static final String ISSUE_FIELD_KEY = "ISSUE_NUM"; private static final String JIRA_KEY_PREFIX = "HIVE-"; - /** * Looks up the current queue of the precommit job on a jenkins instance (specified by * PTestClient.JENKINS_QUEUE_URL), and checks if current Jira is standing in queue already (i.e. @@ -112,11 +115,15 @@ public class JenkinsQueueUtil { private static String httpGet(String url) throws IOException { - DefaultHttpClient httpClient = new DefaultHttpClient(); + HttpGet request = new HttpGet(url); try { + CloseableHttpClient httpClient = HttpClientBuilder + .create() + .setSslcontext(SSLContexts.custom().useProtocol("TLSv1.2").build()) + .setRetryHandler(new PTestClient.PTestHttpRequestRetryHandler()) + .build(); request.addHeader("content-type", "application/json"); - httpClient.setHttpRequestRetryHandler(new PTestClient.PTestHttpRequestRetryHandler()); HttpResponse httpResponse = httpClient.execute(request); StatusLine statusLine = httpResponse.getStatusLine(); if (statusLine.getStatusCode() != 200) { @@ -124,6 +131,9 @@ public class JenkinsQueueUtil { } String response = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); return response; + } catch (NoSuchAlgorithmException | KeyManagementException e) { + e.printStackTrace(); + throw new IOException(e.getMessage()); } finally { request.abort(); }