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-685] - Knox tests cleanup after Jetty 9 upgrade. Remove extranious stream flush() calls.
Date Wed, 09 Mar 2016 19:03:30 GMT
Repository: knox
Updated Branches:
  refs/heads/master d146064c7 -> df0fe7cef


[KNOX-685] - Knox tests cleanup after Jetty 9 upgrade. Remove extranious stream flush() calls.


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

Branch: refs/heads/master
Commit: df0fe7ceffb89bce681515088bfd90617a95a56e
Parents: d146064
Author: Kevin Minder <kminder@apache.org>
Authored: Wed Mar 9 14:03:24 2016 -0500
Committer: Kevin Minder <kminder@apache.org>
Committed: Wed Mar 9 14:03:24 2016 -0500

----------------------------------------------------------------------
 .../filter/rewrite/api/UrlRewriteServletFilter.java     |  5 +++++
 .../gateway/filter/rewrite/impl/UrlRewriteResponse.java |  2 +-
 .../filter/rewrite/api/UrlRewriteServletFilterTest.java | 12 +++++++-----
 .../jwt/filter/JWTAccessTokenAssertionFilter.java       |  2 +-
 .../jwt/filter/JWTAuthCodeAssertionFilter.java          |  2 +-
 .../hadoop/gateway/dispatch/UrlConnectionDispatch.java  |  2 +-
 .../services/topology/DefaultTopologyServiceTest.java   |  2 +-
 .../gateway/dispatch/AbstractGatewayDispatch.java       |  2 +-
 .../hadoop/gateway/filter/GatewayResponseWrapper.java   |  2 +-
 .../apache/hadoop/test/mock/MockResponseProvider.java   |  2 +-
 .../java/org/apache/hadoop/test/mock/MockServlet.java   |  8 ++++++--
 11 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilter.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilter.java
index 74ac67a..a9ed62b 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilter.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilter.java
@@ -21,6 +21,7 @@ import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
 import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteRequest;
 import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteResponse;
 import org.apache.hadoop.gateway.util.MimeTypes;
+import org.apache.log4j.Logger;
 
 import javax.activation.MimeType;
 import javax.servlet.FilterChain;
@@ -35,6 +36,8 @@ import java.io.IOException;
  */
 public class UrlRewriteServletFilter extends AbstractGatewayFilter {
 
+  Logger LOG = Logger.getLogger(UrlRewriteServletFilter.class.getName());
+
   public static final String REQUEST_URL_RULE_PARAM = "request.url";
   public static final String REQUEST_HEADERS_FILTER_PARAM = "request.headers";
   public static final String REQUEST_COOKIES_FILTER_PARAM = "request.cookies";
@@ -54,10 +57,12 @@ public class UrlRewriteServletFilter extends AbstractGatewayFilter {
   @Override
   protected void doFilter( HttpServletRequest request, HttpServletResponse response, FilterChain
chain )
       throws IOException, ServletException {
+    LOG.debug("URL-REWRITE-SERVLET-FILTER:DO-FILTER: BEGIN");
     FilterConfig config = getConfig();
     UrlRewriteRequest rewriteRequest = new UrlRewriteRequest( config, request );
     UrlRewriteResponse rewriteResponse = new UrlRewriteResponse( config, rewriteRequest,
response );
     chain.doFilter( rewriteRequest, rewriteResponse );
+    LOG.debug("URL-REWRITE-SERVLET-FILTER:DO-FILTER: END");
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index 3a85516..5e4aae3 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -182,7 +182,7 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
         mimeType, null, inStream, rewriter, this, UrlRewriter.Direction.OUT, filterContentConfig
);
     outStream = (isGzip) ? new GZIPOutputStream(output) : output;
     IOUtils.copyLarge( filteredInput, outStream, new byte[STREAM_BUFFER_SIZE] );
-    outStream.flush();
+    //KNOX-685: outStream.flush();
     outStream.close();
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
index 5c8a47e..19dee66 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.test.log.NoOpLogger;
 import org.apache.hadoop.test.mock.MockInteraction;
 import org.apache.hadoop.test.mock.MockServlet;
 import org.apache.log4j.Appender;
+import org.apache.log4j.Logger;
 import org.eclipse.jetty.http.HttpHeader;
 import org.eclipse.jetty.servlet.FilterHolder;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -63,6 +64,8 @@ import static org.xmlmatchers.transform.XmlConverters.the;
 
 public class UrlRewriteServletFilterTest {
 
+  Logger LOG = Logger.getLogger(UrlRewriteServletFilterTest.class);
+
   private ServletTester server;
   private HttpTester.Request request;
   private HttpTester.Response response;
@@ -100,7 +103,6 @@ public class UrlRewriteServletFilterTest {
     servlet.setServlet( new MockServlet( "mock-servlet", interactions ) );
 
     server.start();
-    server.getConnector().setIdleTimeout( 30 * 1000 );
 
     interaction = new MockInteraction();
     request = HttpTester.newRequest();
@@ -115,13 +117,13 @@ public class UrlRewriteServletFilterTest {
   }
 
   private void execute() throws Exception {
-    System.out.println( "REQUEST=" + request );
+    LOG.debug( "REQUEST=" + request );
     ByteBuffer requestBuffer = request.generate();
-    System.out.println( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
+    LOG.debug( "REQUEST-BUFFER=[" + new String(requestBuffer.array(),0,requestBuffer.limit())
+ "]" );
     ByteBuffer responseBuffer = server.getResponses( requestBuffer );
     response = HttpTester.parseResponse( responseBuffer );
-    System.out.println( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
-    System.out.println( "RESPONSE=" + response );
+    LOG.debug( "RESPONSE-BUFFER=[" + new String(responseBuffer.array(),0,responseBuffer.limit())
+ "]" );
+    LOG.debug( "RESPONSE=" + response );
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
index d34c7df..6db6f6c 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
@@ -124,7 +124,7 @@ public class JWTAccessTokenAssertionFilter extends AbstractIdentityAssertionFilt
       jsonResponse = JsonUtils.renderAsJsonString(map);
       
       response.getWriter().write(jsonResponse);
-      response.getWriter().flush();
+      //KNOX-685: response.getWriter().flush();
       return; // break filter chain
     }
     else {

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
index c985be9..43ca88e 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
@@ -87,7 +87,7 @@ public class JWTAuthCodeAssertionFilter extends AbstractIdentityAssertionFilter
         String jsonResponse = JsonUtils.renderAsJsonString(map);
         
         response.getWriter().write(jsonResponse);
-        response.getWriter().flush();
+        //KNOX-685: response.getWriter().flush();
       } catch (TokenServiceException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
index 25de087..80cb4ea 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
@@ -143,7 +143,7 @@ public class UrlConnectionDispatch extends AbstractGatewayFilter {
         try {
           IOUtils.copy( input, output );
         } finally {
-          output.flush();
+          //KNOX-685: output.flush();
           input.close();
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-server/src/test/java/org/apache/hadoop/gateway/services/topology/DefaultTopologyServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/services/topology/DefaultTopologyServiceTest.java
b/gateway-server/src/test/java/org/apache/hadoop/gateway/services/topology/DefaultTopologyServiceTest.java
index d381aa8..a8c84ad 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/services/topology/DefaultTopologyServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/services/topology/DefaultTopologyServiceTest.java
@@ -64,7 +64,7 @@ public class DefaultTopologyServiceTest {
     InputStream input = ClassLoader.getSystemResourceAsStream(resource);
     OutputStream output = FileUtils.openOutputStream(file);
     IOUtils.copy(input, output);
-    output.flush();
+    //KNOX-685: output.flush();
     input.close();
     output.close();
     file.setLastModified(timestamp);

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
index 2cc1dc0..622d37b 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
@@ -61,7 +61,7 @@ public abstract class AbstractGatewayDispatch implements Dispatch {
       } else {
         OutputStream output = response.getOutputStream();
         IOUtils.copyBytes( stream, output, STREAM_COPY_BUFFER_SIZE );
-        output.flush();
+        //KNOX-685: output.flush();
         output.close();
       }
 //    }

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-spi/src/main/java/org/apache/hadoop/gateway/filter/GatewayResponseWrapper.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/filter/GatewayResponseWrapper.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/filter/GatewayResponseWrapper.java
index 15f0e14..d5342ed 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/filter/GatewayResponseWrapper.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/filter/GatewayResponseWrapper.java
@@ -61,7 +61,7 @@ public abstract class GatewayResponseWrapper extends HttpServletResponseWrapper
   @Override
   public void streamResponse( InputStream input, OutputStream output ) throws IOException
{
     IOUtils.copyBytes( input, output, STREAM_COPY_BUFFER_SIZE );
-    output.flush();
+    //KNOX-685: output.flush();
     output.close();
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
index b2dd206..3592d1a 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
@@ -153,7 +153,7 @@ public class MockResponseProvider {
     response.flushBuffer();
     if( entity != null ) {
       response.getOutputStream().write( entity );
-      response.getOutputStream().flush();
+      //KNOX-685: response.getOutputStream().flush();
       response.getOutputStream().close();
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/df0fe7ce/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockServlet.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockServlet.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockServlet.java
index d200b78..03f3efe 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockServlet.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockServlet.java
@@ -24,10 +24,14 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.Queue;
 
+import org.apache.log4j.Logger;
+
 import static org.junit.Assert.fail;
 
 public class MockServlet extends HttpServlet {
 
+  Logger LOG = Logger.getLogger(MockServlet.class.getName());
+
   public String name;
   public Queue<MockInteraction> interactions;
 
@@ -38,7 +42,7 @@ public class MockServlet extends HttpServlet {
 
   @Override
   protected void service( HttpServletRequest request, HttpServletResponse response ) throws
ServletException, IOException {
-    System.out.println( "MOCK-SERLVET-REQUEST: " + request.getMethod() + " " + request.getRequestURL()
+ "?" + request.getQueryString() );
+    LOG.debug( "MOCK-SERLVET-REQUEST: " + request.getMethod() + " " + request.getRequestURL()
+ "?" + request.getQueryString() );
     try {
       if( interactions.isEmpty() ) {
         fail( "Mock servlet " + name + " received a request but the expected interaction
queue is empty." );
@@ -46,7 +50,7 @@ public class MockServlet extends HttpServlet {
       MockInteraction interaction = interactions.remove();
       interaction.expect().match( request );
       interaction.respond().apply( response );
-      System.out.println( "MOCK-SERVLET-RESPONSE: " + response.getStatus() );
+      LOG.debug( "MOCK-SERVLET-RESPONSE: " + response.getStatus() );
     } catch( AssertionError e ) {
       e.printStackTrace(); // I18N not required.
       throw new ServletException( e );


Mime
View raw message