hive git commit: HIVE-19228: Remove commons-httpclient 3.x usage (Janaki Lahorani reviewed by Aihua Xu)

2018-06-11 Thread prasanthj
Repository: hive
Updated Branches:
  refs/heads/branch-3 66ed015db -> 81a4bdd75


HIVE-19228: Remove commons-httpclient 3.x usage (Janaki Lahorani reviewed by 
Aihua Xu)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/81a4bdd7
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/81a4bdd7
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/81a4bdd7

Branch: refs/heads/branch-3
Commit: 81a4bdd75828d189969841c068a224bda31a35d7
Parents: 66ed015
Author: Aihua Xu 
Authored: Wed May 9 10:56:32 2018 -0700
Committer: Prasanth Jayachandran 
Committed: Mon Jun 11 16:45:20 2018 -0700

--
 .../apache/hive/jdbc/TestActivePassiveHA.java   | 99 +---
 pom.xml |  6 --
 ql/pom.xml  | 15 ---
 .../hive/ql/parse/LoadSemanticAnalyzer.java | 16 +++-
 .../apache/hive/service/server/HiveServer2.java | 52 ++
 5 files changed, 111 insertions(+), 77 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/81a4bdd7/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
--
diff --git 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
index c55271f..4055f13 100644
--- 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
+++ 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
@@ -36,11 +36,6 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.OptionsMethod;
 import org.apache.curator.test.TestingServer;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
@@ -54,9 +49,22 @@ import 
org.apache.hive.service.server.HS2ActivePassiveHARegistryClient;
 import org.apache.hive.service.server.HiveServer2Instance;
 import org.apache.hive.service.server.TestHS2HttpServerPam;
 import org.apache.hive.service.servlet.HS2Peers;
+import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHeaders;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.StatusLine;
+import org.apache.http.util.EntityUtils;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.util.B64Code;
+import org.eclipse.jetty.util.StringUtil;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -406,7 +414,7 @@ public class TestActivePassiveHA {
   assertEquals("true", sendGet(url1, true));
 
   // trigger failover on miniHS2_1 without authorization header
-  assertEquals("Unauthorized", sendDelete(url1, false));
+  assertTrue(sendDelete(url1, false).contains("Unauthorized"));
   assertTrue(sendDelete(url1, true).contains("Failover successful!"));
   assertEquals(true, miniHS2_1.getNotLeaderTestFuture().get());
   assertEquals(false, miniHS2_1.isLeader());
@@ -541,56 +549,79 @@ public class TestActivePassiveHA {
   }
 
   private String sendGet(String url, boolean enableAuth) throws Exception {
-return sendAuthMethod(new GetMethod(url), enableAuth, false);
+return sendAuthMethod(new HttpGet(url), enableAuth, false);
   }
 
   private String sendGet(String url, boolean enableAuth, boolean enableCORS) 
throws Exception {
-return sendAuthMethod(new GetMethod(url), enableAuth, enableCORS);
+return sendAuthMethod(new HttpGet(url), enableAuth, enableCORS);
   }
 
   private String sendDelete(String url, boolean enableAuth) throws Exception {
-return sendAuthMethod(new DeleteMethod(url), enableAuth, false);
+return sendAuthMethod(new HttpDelete(url), enableAuth, false);
   }
 
   private String sendDelete(String url, boolean enableAuth, boolean 
enableCORS) throws Exception {
-return sendAuthMethod(new DeleteMethod(url), enableAuth, enableCORS);
+return sendAuthMethod(new HttpDelete(url), enableAuth, enableCORS);
   }
 
-  private String sendAuthMethod(HttpMethodBase method, boolean enableAuth, 
boolean enableCORS) throws Exception {
-HttpClient client = new 

hive git commit: HIVE-19228: Remove commons-httpclient 3.x usage (Janaki Lahorani reviewed by Aihua Xu)

2018-05-09 Thread aihuaxu
Repository: hive
Updated Branches:
  refs/heads/master e1e497574 -> f2172cdbc


HIVE-19228: Remove commons-httpclient 3.x usage (Janaki Lahorani reviewed by 
Aihua Xu)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/f2172cdb
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/f2172cdb
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/f2172cdb

Branch: refs/heads/master
Commit: f2172cdbc3af92e18db68c3daac44a73e92eaf48
Parents: e1e4975
Author: Aihua Xu 
Authored: Wed May 9 10:56:32 2018 -0700
Committer: Aihua Xu 
Committed: Wed May 9 11:27:45 2018 -0700

--
 .../apache/hive/jdbc/TestActivePassiveHA.java   | 99 +---
 pom.xml |  6 --
 ql/pom.xml  | 15 ---
 .../hive/ql/parse/LoadSemanticAnalyzer.java | 16 +++-
 .../apache/hive/service/server/HiveServer2.java | 52 ++
 5 files changed, 111 insertions(+), 77 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/f2172cdb/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
--
diff --git 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
index c55271f..4055f13 100644
--- 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
+++ 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java
@@ -36,11 +36,6 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.OptionsMethod;
 import org.apache.curator.test.TestingServer;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
@@ -54,9 +49,22 @@ import 
org.apache.hive.service.server.HS2ActivePassiveHARegistryClient;
 import org.apache.hive.service.server.HiveServer2Instance;
 import org.apache.hive.service.server.TestHS2HttpServerPam;
 import org.apache.hive.service.servlet.HS2Peers;
+import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHeaders;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.StatusLine;
+import org.apache.http.util.EntityUtils;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.util.B64Code;
+import org.eclipse.jetty.util.StringUtil;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -406,7 +414,7 @@ public class TestActivePassiveHA {
   assertEquals("true", sendGet(url1, true));
 
   // trigger failover on miniHS2_1 without authorization header
-  assertEquals("Unauthorized", sendDelete(url1, false));
+  assertTrue(sendDelete(url1, false).contains("Unauthorized"));
   assertTrue(sendDelete(url1, true).contains("Failover successful!"));
   assertEquals(true, miniHS2_1.getNotLeaderTestFuture().get());
   assertEquals(false, miniHS2_1.isLeader());
@@ -541,56 +549,79 @@ public class TestActivePassiveHA {
   }
 
   private String sendGet(String url, boolean enableAuth) throws Exception {
-return sendAuthMethod(new GetMethod(url), enableAuth, false);
+return sendAuthMethod(new HttpGet(url), enableAuth, false);
   }
 
   private String sendGet(String url, boolean enableAuth, boolean enableCORS) 
throws Exception {
-return sendAuthMethod(new GetMethod(url), enableAuth, enableCORS);
+return sendAuthMethod(new HttpGet(url), enableAuth, enableCORS);
   }
 
   private String sendDelete(String url, boolean enableAuth) throws Exception {
-return sendAuthMethod(new DeleteMethod(url), enableAuth, false);
+return sendAuthMethod(new HttpDelete(url), enableAuth, false);
   }
 
   private String sendDelete(String url, boolean enableAuth, boolean 
enableCORS) throws Exception {
-return sendAuthMethod(new DeleteMethod(url), enableAuth, enableCORS);
+return sendAuthMethod(new HttpDelete(url), enableAuth, enableCORS);
   }
 
-  private String sendAuthMethod(HttpMethodBase method, boolean enableAuth, 
boolean enableCORS) throws Exception {
-