You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2011/03/18 02:57:16 UTC

svn commit: r1082790 - in /hbase/branches/0.90/src: main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java

Author: apurtell
Date: Fri Mar 18 01:57:15 2011
New Revision: 1082790

URL: http://svn.apache.org/viewvc?rev=1082790&view=rev
Log:
HBASE-3275 [rest] No gzip/deflat content encoding support; fix error handling in GzipFilter

Modified:
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java?rev=1082790&r1=1082789&r2=1082790&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/rest/filter/GzipFilter.java Fri Mar 18 01:57:15 2011
@@ -1,6 +1,27 @@
+/*
+ * Copyright 2010 The Apache Software Foundation
+ *
+ * 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.hbase.rest.filter;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -50,8 +71,12 @@ public class GzipFilter implements Filte
       response = new GZIPResponseWrapper(response);
     }
     chain.doFilter(request, response);
-    if ((response instanceof GZIPResponseWrapper)) {
-      ((GZIPResponseStream)response.getOutputStream()).finish();
+    if (response instanceof GZIPResponseWrapper) {
+      OutputStream os = response.getOutputStream();
+      if (os instanceof GZIPResponseStream) {
+        ((GZIPResponseStream)os).finish();
+      }
     }
   }
+
 }
\ No newline at end of file

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java?rev=1082790&r1=1082789&r2=1082790&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/rest/TestGzipFilter.java Fri Mar 18 01:57:15 2011
@@ -120,13 +120,16 @@ public class TestGzipFilter {
 
   @Test
   public void testErrorNotGzipped() throws Exception {
-    String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_2;
     Header[] headers = new Header[2];
     headers[0] = new Header("Accept", Constants.MIMETYPE_BINARY);
     headers[1] = new Header("Accept-Encoding", "gzip");
-    Response response = client.get(path, headers);
+    Response response = client.get("/" + TABLE + "/" + ROW_1 + "/" + COLUMN_2, headers);
     assertEquals(response.getCode(), 404);
     String contentEncoding = response.getHeader("Content-Encoding");
     assertTrue(contentEncoding == null || !contentEncoding.contains("gzip"));
+    response = client.get("/" + TABLE, headers);
+    assertEquals(response.getCode(), 405);
+    contentEncoding = response.getHeader("Content-Encoding");
+    assertTrue(contentEncoding == null || !contentEncoding.contains("gzip"));
   }
 }
\ No newline at end of file