knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject knox git commit: [KNOX-638] - Hive dispatch failing for secure clusters
Date Thu, 10 Dec 2015 14:33:39 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.7.0 dae628e6e -> 5f148ce08


[KNOX-638] - Hive dispatch failing for secure clusters

(cherry picked from commit ffc4ef94f63f9b3fc407265a8b3b509446379360)


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

Branch: refs/heads/v0.7.0
Commit: 5f148ce083d364070bada01240696d1c9744c3fd
Parents: dae628e
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Wed Dec 9 22:40:00 2015 -0500
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Wed Dec 9 22:40:29 2015 -0500

----------------------------------------------------------------------
 CHANGES                                         |  1 +
 .../hadoop/gateway/hive/HiveDispatch.java       |  3 +-
 .../hadoop/gateway/hive/HiveHaDispatch.java     |  3 +-
 .../gateway/dispatch/DefaultDispatch.java       |  5 +-
 .../impl/DefaultConfigurationInjector.java      |  7 ++-
 .../hadoop/gateway/config/OptionalTest.java     | 59 ++++++++++++++++++++
 6 files changed, 72 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2dd2730..ab1206d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,7 @@ Release Notes - Apache Knox - Version 0.7.0
     * [KNOX-394] - Request and response URLs must be parsed as literals not templates
     * [KNOX-623] - Gateway provider rewriter doesn't support boolean attributes in HTML.
     * [KNOX-633] - Upgrade apache commons-collections
+    * [KNOX-638] - Hive dispatch failing for secure clusters
 
 ------------------------------------------------------------------------------
 Release Notes - Apache Knox - Version 0.6.0

http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java
index ce1b5de..bdfb1f8 100644
--- a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java
+++ b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatch.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.gateway.hive;
 
 import org.apache.hadoop.gateway.config.Configure;
+import org.apache.hadoop.gateway.config.Default;
 import org.apache.hadoop.gateway.dispatch.DefaultDispatch;
 import org.apache.hadoop.gateway.security.SubjectUtils;
 import org.apache.http.auth.UsernamePasswordCredentials;
@@ -43,7 +44,7 @@ public class HiveDispatch extends DefaultDispatch {
   }
 
   @Configure
-  public void setBasicAuthPreemptive( boolean basicAuthPreemptive ) {
+  public void setBasicAuthPreemptive( @Default("false") boolean basicAuthPreemptive ) {
     this.basicAuthPreemptive = basicAuthPreemptive;
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java
index 6915aa7..8a3dcf2 100644
--- a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java
+++ b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHaDispatch.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.gateway.hive;
 
 import org.apache.hadoop.gateway.config.Configure;
+import org.apache.hadoop.gateway.config.Default;
 import org.apache.hadoop.gateway.ha.dispatch.DefaultHaDispatch;
 import org.apache.http.client.methods.HttpUriRequest;
 
@@ -37,7 +38,7 @@ public class HiveHaDispatch extends DefaultHaDispatch {
   }
 
   @Configure
-  public void setBasicAuthPreemptive(boolean basicAuthPreemptive) {
+  public void setBasicAuthPreemptive(@Default("false")boolean basicAuthPreemptive) {
     this.basicAuthPreemptive = basicAuthPreemptive;
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
index 9555ffa..ea9b992 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
@@ -26,6 +26,7 @@ import org.apache.hadoop.gateway.audit.api.Auditor;
 import org.apache.hadoop.gateway.audit.api.ResourceType;
 import org.apache.hadoop.gateway.audit.log4j.audit.AuditConstants;
 import org.apache.hadoop.gateway.config.Configure;
+import org.apache.hadoop.gateway.config.Default;
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
@@ -84,7 +85,7 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
   }
 
   @Configure
-  protected void setReplayBufferSize(int size) {
+  protected void setReplayBufferSize(@Default("-1")int size) {
     replayBufferSize = size;
   }
 
@@ -215,7 +216,7 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
         if (replayBufferSize < 0) {
           replayBufferSize = config.getHttpServerRequestBuffer();
         }
-        if (!delegationTokenPresent) {
+        if (!delegationTokenPresent && replayBufferSize > 0 ) {
           entity = new PartiallyRepeatableHttpEntity(entity, replayBufferSize);
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
b/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
index 8b86ba1..8b7e13a 100755
--- a/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
+++ b/gateway-util-configinjector/src/main/java/org/apache/hadoop/gateway/config/impl/DefaultConfigurationInjector.java
@@ -101,7 +101,7 @@ public class DefaultConfigurationInjector implements ConfigurationInjector
{
             argValue = convertValue( target, argName, strValue, argTypes[i] );
           } else {
             throw new ConfigurationException( String.format(
-                "Failed to find configuration for %s of %s via %s",
+                "Failed to find configuration for %s as %s of %s via %s",
                 bndName, argName, target.getClass().getName(), adapter.getClass().getName()
) );
           }
         }
@@ -141,7 +141,10 @@ public class DefaultConfigurationInjector implements ConfigurationInjector
{
           "Failed to retrieve configuration for %s bound to %s of %s via %s",
           bind, name, target.getClass().getName(), adapter.getClass().getName() ), e );
     }
-    value = convertValue( target, name, value, type );
+    // Otherwise null sometimes ends up being converted to 0.
+    if( value != null ) {
+      value = convertValue( target, name, value, type );
+    }
     return value;
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f148ce0/gateway-util-configinjector/src/test/java/org/apache/hadoop/gateway/config/OptionalTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-configinjector/src/test/java/org/apache/hadoop/gateway/config/OptionalTest.java
b/gateway-util-configinjector/src/test/java/org/apache/hadoop/gateway/config/OptionalTest.java
new file mode 100644
index 0000000..2d316c7
--- /dev/null
+++ b/gateway-util-configinjector/src/test/java/org/apache/hadoop/gateway/config/OptionalTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.config;
+
+import org.junit.Test;
+
+import static org.apache.hadoop.gateway.config.ConfigurationInjectorBuilder.configuration;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+public class OptionalTest {
+
+  class FieldTarget {
+    @Configure
+    @Optional
+    private int num = -1;
+  }
+
+  class SetterTarget {
+    private int num = -1;
+    @Configure
+    public void setNum( @Default("-1") int n ) { this.num = n; };
+  }
+
+  @Test
+  public void testDefaultInject() {
+    FieldTarget fieldTarget = new FieldTarget();
+    configuration()
+        .target( fieldTarget )
+        .source( System.getProperties() )
+        //.bind( "user", "user.name" )
+        .inject();
+    assertThat( fieldTarget.num, is(-1) );
+
+    SetterTarget setterTarget = new SetterTarget();
+    configuration()
+        .target( setterTarget )
+        .source( System.getProperties() )
+            //.bind( "user", "user.name" )
+        .inject();
+    assertThat( fieldTarget.num, is(-1) );
+  }
+
+}


Mime
View raw message