Repository: knox Updated Branches: refs/heads/master e7262162a -> 8b1329b22
KNOX-1672 - Cleanup deprecated API usage Signed-off-by: Kevin Risden <kris...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/8b1329b2 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/8b1329b2 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/8b1329b2 Branch: refs/heads/master Commit: 8b1329b221b3e5862b80cacfce939e80d09a175d Parents: e726216 Author: Kevin Risden <kris...@apache.org> Authored: Tue Dec 11 14:13:16 2018 -0500 Committer: Kevin Risden <kris...@apache.org> Committed: Wed Dec 12 12:58:05 2018 -0500 ---------------------------------------------------------------------- .../gateway/shirorealm/KnoxLdapRealmTest.java | 3 +- .../gateway/shirorealm/KnoxPamRealmTest.java | 1 + .../provider/impl/BaseZookeeperURLManager.java | 15 +-- gateway-provider-rewrite/pom.xml | 4 + .../rewrite/impl/json/JsonFilterReader.java | 4 +- .../rewrite/impl/xml/XmlFilterReader.java | 4 +- .../knox/gateway/shirorealm/KnoxLdapRealm.java | 6 +- .../apache/knox/gateway/GatewayCommandLine.java | 4 +- .../org/apache/knox/gateway/util/KnoxCLI.java | 5 +- .../knox/gateway/jetty/JettyPathMapTest.java | 64 ---------- .../knox/gateway/jetty/SslSocketTest.java | 128 ------------------- .../knox/gateway/hbase/HBaseDispatchTest.java | 3 +- .../knox/gateway/hive/HiveDispatchUtils.java | 8 +- .../dispatch/CappedBufferHttpEntity.java | 1 + .../dispatch/KnoxSpnegoAuthSchemeFactory.java | 2 +- .../org/apache/knox/examples/WordCount.java | 2 +- pom.xml | 6 + 17 files changed, 39 insertions(+), 221 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealmTest.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealmTest.java b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealmTest.java index 2c1fb87..fbcc96d 100644 --- a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealmTest.java +++ b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxLdapRealmTest.java @@ -24,8 +24,8 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +@SuppressWarnings("deprecation") public class KnoxLdapRealmTest { - @Test public void setGetSearchBase() { KnoxLdapRealm realm = new KnoxLdapRealm(); @@ -102,5 +102,4 @@ public class KnoxLdapRealmTest { realm.setSearchBase("dc=knox,dc=example,dc=com"); assertEquals(realm.getGroupSearchBase(), "dc=knox,dc=example,dc=com"); } - } http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java ---------------------------------------------------------------------- diff --git a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java index 1a32ef3..30f9adf 100644 --- a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java +++ b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java @@ -30,6 +30,7 @@ import static org.easymock.EasyMock.replay; import static org.junit.Assert.assertNotNull; import static org.junit.Assume.assumeTrue; +@SuppressWarnings("deprecation") public class KnoxPamRealmTest { @Test public void setService() { http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java ---------------------------------------------------------------------- diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java index c1005ee..65f42ec 100644 --- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java +++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java @@ -17,12 +17,12 @@ */ package org.apache.knox.gateway.ha.provider.impl; +import java.io.IOException; import java.security.Principal; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.commons.io.IOUtils; import org.apache.knox.gateway.config.GatewayConfig; import org.apache.knox.gateway.dispatch.KnoxSpnegoAuthSchemeFactory; import org.apache.knox.gateway.ha.provider.HaServiceConfig; @@ -161,10 +161,7 @@ public abstract class BaseZookeeperURLManager implements URLManager { */ protected List<String> validateHosts(List<String> hosts, String suffix, String acceptHeader) { List<String> result = new ArrayList<>(); - - CloseableHttpClient client = buildHttpClient(); - - try { + try (CloseableHttpClient client = buildHttpClient()) { for(String host: hosts) { try { HttpGet get = new HttpGet(host + suffix); @@ -179,14 +176,12 @@ public abstract class BaseZookeeperURLManager implements URLManager { if (response != null) { result.add(host); } - } catch (Exception ex) { - // ignore host + } catch (IOException e) { + // ignore host exception } } - } catch (Exception e) { + } catch (IOException e) { // Ignore errors - } finally { - IOUtils.closeQuietly(client); } return result; http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-provider-rewrite/pom.xml ---------------------------------------------------------------------- diff --git a/gateway-provider-rewrite/pom.xml b/gateway-provider-rewrite/pom.xml index 6b8d3eb..9c16ed0 100644 --- a/gateway-provider-rewrite/pom.xml +++ b/gateway-provider-rewrite/pom.xml @@ -71,6 +71,10 @@ <artifactId>commons-lang3</artifactId> </dependency> <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + </dependency> + <dependency> <groupId>net.htmlparser.jericho</groupId> <artifactId>jericho-html</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReader.java ---------------------------------------------------------------------- diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReader.java index 669ed90..2c205dd 100644 --- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReader.java +++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/json/JsonFilterReader.java @@ -175,7 +175,7 @@ class JsonFilterReader extends Reader { ((ArrayNode)parent.node ).add( child.node ); break; case START_OBJECT: - ((ObjectNode)parent.node ).put( child.field, child.node ); + ((ObjectNode)parent.node ).set( child.field, child.node ); break; default: throw new IllegalStateException(); @@ -240,7 +240,7 @@ class JsonFilterReader extends Reader { ((ArrayNode)parent.node ).add( child.node ); break; case START_OBJECT: - ((ObjectNode)parent.node ).put( child.field, child.node ); + ((ObjectNode)parent.node ).set( child.field, child.node ); break; default: throw new IllegalStateException(); http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java ---------------------------------------------------------------------- diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java index 743cfbe..95b9746 100644 --- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java +++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java @@ -17,7 +17,7 @@ */ package org.apache.knox.gateway.filter.rewrite.impl.xml; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFilterApplyDescriptor; import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFilterBufferDescriptor; import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFilterContentDescriptor; @@ -533,7 +533,7 @@ public abstract class XmlFilterReader extends Reader { writer.write( value ); writer.write( "]]>" ); } else { - writer.write( StringEscapeUtils.escapeXml( value ) ); + writer.write( StringEscapeUtils.escapeXml11( value ) ); } } } http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java ---------------------------------------------------------------------- diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java index 1352a25..7521577 100644 --- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java +++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java @@ -40,7 +40,7 @@ import org.apache.shiro.crypto.hash.DefaultHashService; import org.apache.shiro.crypto.hash.Hash; import org.apache.shiro.crypto.hash.HashRequest; import org.apache.shiro.crypto.hash.HashService; -import org.apache.shiro.realm.ldap.JndiLdapRealm; +import org.apache.shiro.realm.ldap.DefaultLdapRealm; import org.apache.shiro.realm.ldap.LdapContextFactory; import org.apache.shiro.realm.ldap.LdapUtils; import org.apache.shiro.subject.MutablePrincipalCollection; @@ -77,7 +77,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * Implementation of {@link org.apache.shiro.realm.ldap.JndiLdapRealm} that also + * Implementation of {@link org.apache.shiro.realm.ldap.DefaultLdapRealm} that also * returns each user's groups. * This implementation is heavily based on org.apache.isis.security.shiro.IsisLdapRealm. * @@ -125,7 +125,7 @@ import java.util.regex.Pattern; * * </pre> */ -public class KnoxLdapRealm extends JndiLdapRealm { +public class KnoxLdapRealm extends DefaultLdapRealm { private static GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class ); KnoxShiroMessages ShiroLog = MessagesFactory.get( KnoxShiroMessages.class ); http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java index e52bab5..98521de 100644 --- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java +++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java @@ -19,11 +19,11 @@ package org.apache.knox.gateway; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.PosixParser; import org.apache.knox.gateway.i18n.resources.ResourcesFactory; import java.io.OutputStreamWriter; @@ -36,7 +36,7 @@ import static org.apache.commons.cli.HelpFormatter.DEFAULT_LEFT_PAD; public class GatewayCommandLine { public static CommandLine parse( String[] args ) throws ParseException { - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); return parser.parse( createCommandLine(), args ); } http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java index 300edc1..cc3a574 100644 --- a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java +++ b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java @@ -26,10 +26,10 @@ import org.apache.hadoop.util.ToolRunner; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; import org.apache.knox.gateway.GatewayCommandLine; import org.apache.knox.gateway.config.GatewayConfig; import org.apache.knox.gateway.config.impl.GatewayConfigImpl; @@ -1322,6 +1322,7 @@ public class KnoxCLI extends Configured implements Tool { protected Subject getSubject(Ini config) throws BadSubjectException { try { ThreadContext.unbindSubject(); + @SuppressWarnings("deprecation") Factory factory = new IniSecurityManagerFactory(config); org.apache.shiro.mgt.SecurityManager securityManager = (org.apache.shiro.mgt.SecurityManager) factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); @@ -1667,7 +1668,7 @@ public class KnoxCLI extends Configured implements Tool { if(ctx == null) { client = HttpClients.createDefault(); } else { - client = HttpClients.custom().setSslcontext(ctx).build(); + client = HttpClients.custom().setSSLContext(ctx).build(); } HttpGet request; http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-server/src/test/java/org/apache/knox/gateway/jetty/JettyPathMapTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/JettyPathMapTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/JettyPathMapTest.java deleted file mode 100644 index 3de8b44..0000000 --- a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/JettyPathMapTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.knox.gateway.jetty; - -import org.eclipse.jetty.http.PathMap; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -//@Category( { UnitTests.class, FastTests.class } ) -public class JettyPathMapTest { - - //@Ignore( "This doesn't work like I expected." ) - //@Test - public void testPathMatching() { - PathMap map; - - map = new PathMap(); - map.put( "/path", "/path" ); - assertThat(map.match("/path"), is("/path") ); - - map = new PathMap(); - map.put( "/path", "/path" ); - map.put( "/path/", "/path/" ); - assertThat(map.match("/path"), is("/path") ); - assertThat(map.match("/path/"), is("/path/") ); - - map = new PathMap(); - map.put( "/path/*", "/path/*" ); - map.put( "/path", "/path" ); - map.put( "/path/", "/path/" ); - assertThat(map.match("/path"), is("/path") ); - assertThat(map.match("/path/"), is("/path/") ); - assertThat(map.match("/path/sub"), is("/path/*") ); - - map = new PathMap(); - map.put( "/path", "/path" ); - map.put( "/path/", "/path/" ); - map.put( "/path/*", "/path/*" ); - assertThat(map.match( "/path/sub" ), is("/path/*") ); - - // Here the addition of the * path "overwrites" the exact matches. - // Above this worked if the /path and /path/ were added after /path/*. - assertThat(map.match("/path"), is("/path") ); - assertThat(map.match("/path/"), is("/path/") ); - - } - -} http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java deleted file mode 100644 index e4e0d35..0000000 --- a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.knox.gateway.jetty; - -import org.apache.http.HttpVersion; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpParams; -import org.apache.http.params.HttpProtocolParams; -import org.apache.knox.test.category.ManualTests; -import org.apache.knox.test.category.MediumTests; -import org.eclipse.jetty.server.Server; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.net.ssl.SSLServerSocket; -import javax.net.ssl.SSLServerSocketFactory; -import javax.net.ssl.SSLSocket; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.InetSocketAddress; -import java.nio.charset.StandardCharsets; - -@Category( { ManualTests.class, MediumTests.class } ) -public class SslSocketTest { - - Logger log = LoggerFactory.getLogger( SslSocketTest.class ); - - private Server jetty; - - @BeforeClass - public static void setupSuite() { - System.setProperty( "javax.net.ssl.keyStore", "target/test-classes/server-keystore.jks" ); - System.setProperty( "javax.net.ssl.keyStorePassword", "horton" ); - System.setProperty( "javax.net.ssl.trustStore", "target/test-classes/server-keystore.jks" ); - System.setProperty( "javax.net.ssl.trustStorePassword", "horton" ); - System.setProperty( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" ); - System.setProperty( "javax.net.debug", "ssl" ); - } - - public class SslServer implements Runnable { - - private boolean ready; - - public boolean waitUntilReady() throws InterruptedException { - synchronized( this ) { - while( !ready ) { - this.wait(); - } - } - return ready; - } - - @Override - public void run() { - try { - SSLServerSocketFactory sslserversocketfactory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); - SSLServerSocket sslserversocket = (SSLServerSocket)sslserversocketfactory.createServerSocket( 9999 ); - synchronized( this ) { - ready = true; - this.notifyAll(); - } - SSLSocket sslsocket = (SSLSocket)sslserversocket.accept(); - - InputStream inputstream = sslsocket.getInputStream(); - InputStreamReader inputstreamreader = new InputStreamReader( inputstream, StandardCharsets.UTF_8 ); - BufferedReader bufferedreader = new BufferedReader( inputstreamreader ); - - String string = bufferedreader.readLine(); - System.out.println( string ); - System.out.flush(); - } catch( IOException e ) { - e.printStackTrace(); - } - } - } - - @Ignore - @Test - public void testSsl() throws IOException, InterruptedException { - SslServer server = new SslServer(); - Thread thread = new Thread( server ); - thread.start(); - server.waitUntilReady(); - - HttpParams params = new BasicHttpParams(); - HttpProtocolParams.setVersion( params, HttpVersion.HTTP_1_1 ); - HttpProtocolParams.setContentCharset( params, StandardCharsets.UTF_8.name() ); - params.setBooleanParameter( "http.protocol.expect-continue", false ); - - SSLSocketFactory sslsocketfactory = SSLSocketFactory.getSocketFactory(); - SSLSocket sslsocket = (SSLSocket)sslsocketfactory.createSocket( params ); - - sslsocket.connect( new InetSocketAddress( "localhost", 9999 ) ); - - OutputStream outputstream = sslsocket.getOutputStream(); - OutputStreamWriter outputstreamwriter = new OutputStreamWriter( outputstream, StandardCharsets.UTF_8 ); - BufferedWriter bufferedwriter = new BufferedWriter( outputstreamwriter ); - - bufferedwriter.write( "HELLO\n" ); - bufferedwriter.flush(); - } - -} http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-service-hbase/src/test/java/org/apache/knox/gateway/hbase/HBaseDispatchTest.java ---------------------------------------------------------------------- diff --git a/gateway-service-hbase/src/test/java/org/apache/knox/gateway/hbase/HBaseDispatchTest.java b/gateway-service-hbase/src/test/java/org/apache/knox/gateway/hbase/HBaseDispatchTest.java index 9f98551..822d053 100644 --- a/gateway-service-hbase/src/test/java/org/apache/knox/gateway/hbase/HBaseDispatchTest.java +++ b/gateway-service-hbase/src/test/java/org/apache/knox/gateway/hbase/HBaseDispatchTest.java @@ -34,6 +34,7 @@ import static org.junit.Assert.assertThat; @Category( { UnitTests.class, FastTests.class } ) public class HBaseDispatchTest { + @SuppressWarnings("deprecation") @Test( timeout = TestUtils.SHORT_TIMEOUT ) public void testGetDispatchUrl() throws Exception { HttpServletRequest request; @@ -82,7 +83,5 @@ public class HBaseDispatchTest { EasyMock.replay( request ); uri = dispatch.getDispatchUrl( request ); assertThat( uri.toASCIIString(), is( "http://test-host:42/test,path?test%26name=test%3Dvalue" ) ); - } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatchUtils.java ---------------------------------------------------------------------- diff --git a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatchUtils.java b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatchUtils.java index f0cfbee..59cd5cf 100644 --- a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatchUtils.java +++ b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatchUtils.java @@ -17,6 +17,7 @@ */ package org.apache.knox.gateway.hive; +import org.apache.http.auth.AuthenticationException; import org.apache.knox.gateway.security.SubjectUtils; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.methods.HttpUriRequest; @@ -31,8 +32,11 @@ public class HiveDispatchUtils { if ( principal != null ) { UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(principal, PASSWORD_PLACEHOLDER); - request.addHeader(BasicScheme.authenticate(credentials, "US-ASCII", false)); + try { + request.addHeader(new BasicScheme().authenticate(credentials, request, null)); + } catch (AuthenticationException e) { + // impossible + } } } - } http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java ---------------------------------------------------------------------- diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java index 6ce6bea..70962f1 100644 --- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java +++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java @@ -91,6 +91,7 @@ public class CappedBufferHttpEntity extends HttpEntityWrapper { IOUtils.copy( getContent(), stream ); } + @SuppressWarnings("deprecation") @Override public void consumeContent() throws IOException { throw new UnsupportedOperationException(); http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/KnoxSpnegoAuthSchemeFactory.java ---------------------------------------------------------------------- diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/KnoxSpnegoAuthSchemeFactory.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/KnoxSpnegoAuthSchemeFactory.java index 0e4145a..982d8cc 100644 --- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/KnoxSpnegoAuthSchemeFactory.java +++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/KnoxSpnegoAuthSchemeFactory.java @@ -31,9 +31,9 @@ public class KnoxSpnegoAuthSchemeFactory extends SPNegoSchemeFactory { super(); } + @SuppressWarnings("deprecation") @Override public AuthScheme newInstance(final HttpParams params ) { return new KnoxSpnegoAuthScheme( isStripPort() ); } - } http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/hadoop-examples/src/main/java/org/apache/knox/examples/WordCount.java ---------------------------------------------------------------------- diff --git a/hadoop-examples/src/main/java/org/apache/knox/examples/WordCount.java b/hadoop-examples/src/main/java/org/apache/knox/examples/WordCount.java index cecc23f..e5b124a 100644 --- a/hadoop-examples/src/main/java/org/apache/knox/examples/WordCount.java +++ b/hadoop-examples/src/main/java/org/apache/knox/examples/WordCount.java @@ -74,7 +74,7 @@ public class WordCount { System.err.println( "Usage: wordcount <in> <out>" ); System.exit(2); } - Job job = new Job(conf, "Word Count"); + Job job = Job.getInstance(conf, "Word Count"); job.setJarByClass(WordCount.class); job.setMapperClass(TokenizerMapper.class); job.setCombinerClass(IntSumReducer.class); http://git-wip-us.apache.org/repos/asf/knox/blob/8b1329b2/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index ac8bfbe..5173139 100644 --- a/pom.xml +++ b/pom.xml @@ -154,6 +154,7 @@ <commons-lang.version>2.6</commons-lang.version> <commons-lang3.version>3.8.1</commons-lang3.version> <commons-net.version>3.6</commons-net.version> + <commons-text.version>1.6</commons-text.version> <cors-filter.version>2.6</cors-filter.version> <curator.version>4.0.1</curator.version> <curator-test.version>2.13.0</curator-test.version> @@ -1469,6 +1470,11 @@ <artifactId>commons-net</artifactId> <version>${commons-net.version}</version> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>${commons-text.version}</version> + </dependency> <dependency> <groupId>org.jboss.shrinkwrap</groupId>