hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [43/50] [abbrv] git commit: YARN-2547. Cross Origin Filter throws UnsupportedOperationException upon destroy (Mit Desai via jeagles)
Date Sat, 13 Sep 2014 03:54:49 GMT
YARN-2547. Cross Origin Filter throws UnsupportedOperationException upon destroy (Mit Desai
via jeagles)


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

Branch: refs/heads/HDFS-6581
Commit: 54e5794806bd856da0277510efe63656eed23146
Parents: 3122daa
Author: Jonathan Eagles <jeagles@gmail.com>
Authored: Fri Sep 12 15:35:17 2014 -0500
Committer: Jonathan Eagles <jeagles@gmail.com>
Committed: Fri Sep 12 15:35:17 2014 -0500

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 ++
 .../timeline/webapp/CrossOriginFilter.java      | 12 ++---
 .../timeline/webapp/TestCrossOriginFilter.java  | 49 ++++++++++++++++++++
 3 files changed, 58 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/54e57948/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index bb73dc7..3993f5e 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -214,6 +214,9 @@ Release 2.6.0 - UNRELEASED
     YARN-2229. Changed the integer field of ContainerId to be long type.
     (Tsuyoshi OZAWA via jianhe)
 
+    YARN-2547. Cross Origin Filter throws UnsupportedOperationException upon
+    destroy (Mit Desai via jeagles)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/54e57948/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilter.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilter.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilter.java
index 5a0703d..cceee54 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilter.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilter.java
@@ -150,8 +150,8 @@ public class CrossOriginFilter implements Filter {
     if (allowedMethodsConfig == null) {
       allowedMethodsConfig = ALLOWED_METHODS_DEFAULT;
     }
-    allowedMethods =
-        Arrays.asList(allowedMethodsConfig.trim().split("\\s*,\\s*"));
+    allowedMethods.addAll(
+        Arrays.asList(allowedMethodsConfig.trim().split("\\s*,\\s*")));
     LOG.info("Allowed Methods: " + getAllowedMethodsHeader());
   }
 
@@ -161,8 +161,8 @@ public class CrossOriginFilter implements Filter {
     if (allowedHeadersConfig == null) {
       allowedHeadersConfig = ALLOWED_HEADERS_DEFAULT;
     }
-    allowedHeaders =
-        Arrays.asList(allowedHeadersConfig.trim().split("\\s*,\\s*"));
+    allowedHeaders.addAll(
+        Arrays.asList(allowedHeadersConfig.trim().split("\\s*,\\s*")));
     LOG.info("Allowed Headers: " + getAllowedHeadersHeader());
   }
 
@@ -172,8 +172,8 @@ public class CrossOriginFilter implements Filter {
     if (allowedOriginsConfig == null) {
       allowedOriginsConfig = ALLOWED_ORIGINS_DEFAULT;
     }
-    allowedOrigins =
-        Arrays.asList(allowedOriginsConfig.trim().split("\\s*,\\s*"));
+    allowedOrigins.addAll(
+        Arrays.asList(allowedOriginsConfig.trim().split("\\s*,\\s*")));
     allowAllOrigins = allowedOrigins.contains("*");
     LOG.info("Allowed Origins: " + StringUtils.join(allowedOrigins, ','));
     LOG.info("Allow All Origins: " + allowAllOrigins);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/54e57948/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilter.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilter.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilter.java
index ccc9bbf..e0990f9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilter.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilter.java
@@ -217,6 +217,55 @@ public class TestCrossOriginFilter {
     verify(mockChain).doFilter(mockReq, mockRes);
   }
 
+  @Test
+  public void testCrossOriginFilterAfterRestart() throws ServletException {
+
+    // Setup the configuration settings of the server
+    Map<String, String> conf = new HashMap<String, String>();
+    conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "example.com");
+    conf.put(CrossOriginFilter.ALLOWED_HEADERS, "X-Requested-With,Accept");
+    conf.put(CrossOriginFilter.ALLOWED_METHODS, "GET,POST");
+    FilterConfig filterConfig = new FilterConfigTest(conf);
+
+    // Object under test
+    CrossOriginFilter filter = new CrossOriginFilter();
+    filter.init(filterConfig);
+
+    //verify filter values
+    Assert.assertTrue("Allowed headers do not match",
+        filter.getAllowedHeadersHeader()
+        .compareTo("X-Requested-With,Accept") == 0);
+    Assert.assertTrue("Allowed methods do not match",
+        filter.getAllowedMethodsHeader()
+        .compareTo("GET,POST") == 0);
+    Assert.assertTrue(filter.isOriginAllowed("example.com"));
+
+    //destroy filter values and clear conf
+    filter.destroy();
+    conf.clear();
+
+    // Setup the configuration settings of the server
+    conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "newexample.com");
+    conf.put(CrossOriginFilter.ALLOWED_HEADERS, "Content-Type,Origin");
+    conf.put(CrossOriginFilter.ALLOWED_METHODS, "GET,HEAD");
+    filterConfig = new FilterConfigTest(conf);
+
+    //initialize filter
+    filter.init(filterConfig);
+
+    //verify filter values
+    Assert.assertTrue("Allowed headers do not match",
+        filter.getAllowedHeadersHeader()
+        .compareTo("Content-Type,Origin") == 0);
+    Assert.assertTrue("Allowed methods do not match",
+        filter.getAllowedMethodsHeader()
+        .compareTo("GET,HEAD") == 0);
+    Assert.assertTrue(filter.isOriginAllowed("newexample.com"));
+
+    //destroy filter values
+    filter.destroy();
+  }
+
   private static class FilterConfigTest implements FilterConfig {
 
     final Map<String, String> map;


Mime
View raw message