From e6420fec0af9b8d4f424098688ae4926ff527fcf Mon Sep 17 00:00:00 2001 From: Jonathan Eagles Date: Fri, 5 Sep 2014 19:42:40 -0500 Subject: [PATCH] YARN-2508. Cross Origin configuration parameters prefix are not honored (Mit Desai via jeagles) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../webapp/CrossOriginFilterInitializer.java | 12 +++++++++++- .../webapp/TestCrossOriginFilterInitializer.java | 7 ++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 1a5ea07914f..34a206af6e1 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -181,6 +181,9 @@ Release 2.6.0 - UNRELEASED YARN-2511. Allowed all origins by default when CrossOriginFilter is enabled. (Jonathan Eagles via zjshen) + YARN-2508. Cross Origin configuration parameters prefix are not honored + (Mit Desai via jeagles) + OPTIMIZATIONS BUG FIXES 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/CrossOriginFilterInitializer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilterInitializer.java index 69e0188137a..148cc631ad7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilterInitializer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/CrossOriginFilterInitializer.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.timeline.webapp; +import java.util.HashMap; import java.util.Map; import org.apache.hadoop.conf.Configuration; @@ -37,6 +38,15 @@ public class CrossOriginFilterInitializer extends FilterInitializer { } static Map getFilterParameters(Configuration conf) { - return conf.getValByRegex(PREFIX); + Map filterParams = + new HashMap(); + for (Map.Entry entry : conf.getValByRegex(PREFIX) + .entrySet()) { + String name = entry.getKey(); + String value = entry.getValue(); + name = name.substring(PREFIX.length()); + filterParams.put(name, value); + } + return filterParams; } } 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/TestCrossOriginFilterInitializer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilterInitializer.java index 3199aac5089..cf26368acdf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilterInitializer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestCrossOriginFilterInitializer.java @@ -42,11 +42,8 @@ public class TestCrossOriginFilterInitializer { CrossOriginFilterInitializer.getFilterParameters(conf); // retrieve values - String rootvalue = - filterParameters.get(CrossOriginFilterInitializer.PREFIX + "rootparam"); - String nestedvalue = - filterParameters.get(CrossOriginFilterInitializer.PREFIX - + "nested.param"); + String rootvalue = filterParameters.get("rootparam"); + String nestedvalue = filterParameters.get("nested.param"); String outofscopeparam = filterParameters.get("outofscopeparam"); // verify expected values are in place