YARN-2508. Cross Origin configuration parameters prefix are not honored (Mit Desai via jeagles)

(cherry picked from commit e6420fec0a)
This commit is contained in:
Jonathan Eagles 2014-09-05 19:42:40 -05:00
parent e392229676
commit c47d72d8d2
3 changed files with 16 additions and 6 deletions

View File

@ -158,6 +158,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

View File

@ -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<String, String> getFilterParameters(Configuration conf) {
return conf.getValByRegex(PREFIX);
Map<String, String> filterParams =
new HashMap<String, String>();
for (Map.Entry<String, String> entry : conf.getValByRegex(PREFIX)
.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
name = name.substring(PREFIX.length());
filterParams.put(name, value);
}
return filterParams;
}
}

View File

@ -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