knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [27/49] knox git commit: KNOX-1083 - HttpClient default timeout will be 20 sec
Date Thu, 14 Dec 2017 21:13:14 GMT
KNOX-1083 - HttpClient default timeout will be 20 sec


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

Branch: refs/heads/KNOX-998-Package_Restructuring
Commit: 13287d2c186079aedc2dbaa7bef299845aff0b2a
Parents: 6eacf68
Author: Sandeep More <more@apache.org>
Authored: Tue Dec 5 14:41:00 2017 -0500
Committer: Sandeep More <more@apache.org>
Committed: Tue Dec 5 14:41:00 2017 -0500

----------------------------------------------------------------------
 .../gateway/config/impl/GatewayConfigImpl.java       |  5 +++--
 .../gateway/config/impl/GatewayConfigImplTest.java   | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/13287d2c/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
index 17c2552..f6bb9b0 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
@@ -39,6 +39,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 
 /**
  * The configuration for the Gateway.
@@ -619,7 +620,7 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
   @Override
   public int getHttpClientConnectionTimeout() {
     int t = -1;
-    String s = get( HTTP_CLIENT_CONNECTION_TIMEOUT, null );
+    String s = get( HTTP_CLIENT_CONNECTION_TIMEOUT, String.valueOf(TimeUnit.SECONDS.toMillis(20)));
     if ( s != null ) {
       try {
         t = (int)parseNetworkTimeout( s );
@@ -633,7 +634,7 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
   @Override
   public int getHttpClientSocketTimeout() {
     int t = -1;
-    String s = get( HTTP_CLIENT_SOCKET_TIMEOUT, null );
+    String s = get( HTTP_CLIENT_SOCKET_TIMEOUT, String.valueOf(TimeUnit.SECONDS.toMillis(20))
);
     if ( s != null ) {
       try {
         t = (int)parseNetworkTimeout( s );

http://git-wip-us.apache.org/repos/asf/knox/blob/13287d2c/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
index cd56f11..2c0b47e 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImplTest.java
@@ -5,12 +5,14 @@ import org.hamcrest.CoreMatchers;
 import org.junit.Test;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
@@ -245,4 +247,17 @@ public class GatewayConfigImplTest {
     assertEquals(registryNames.size(), 2);
   }
 
+
+  @Test
+  public void testHTTPDefaultTimeouts() {
+    final GatewayConfigImpl config = new GatewayConfigImpl();
+
+    assertNotEquals(config.getHttpClientConnectionTimeout(), -1);
+    assertNotEquals(config.getHttpClientSocketTimeout(), -1);
+
+    assertEquals(TimeUnit.SECONDS.toMillis(20), config.getHttpClientConnectionTimeout());
+    assertEquals(TimeUnit.SECONDS.toMillis(20), config.getHttpClientSocketTimeout());
+
+  }
+
 }


Mime
View raw message