HADOOP-6871. When the value of a configuration key is set to its unresolved form, it causes an IllegalStateException in Configuration.get() stating that substitution depth is too large. Contributed by Arvind Prabhakar (harsh)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1342626 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ebb1f47db
commit
4709160d75
@ -153,6 +153,11 @@ Trunk (unreleased changes)
|
||||
HADOOP-8413. test-patch.sh gives out the wrong links for
|
||||
newPatchFindbugsWarnings (Colin Patrick McCabe via bobby)
|
||||
|
||||
HADOOP-6871. When the value of a configuration key is set to its
|
||||
unresolved form, it causes the IllegalStateException in
|
||||
Configuration.get() stating that substitution depth is too large.
|
||||
(Arvind Prabhakar via harsh)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-7761. Improve the performance of raw comparisons. (todd)
|
||||
|
@ -617,7 +617,13 @@ private String substituteVars(String expr) {
|
||||
}
|
||||
Matcher match = varPat.matcher("");
|
||||
String eval = expr;
|
||||
Set<String> evalSet = new HashSet<String>();
|
||||
for(int s=0; s<MAX_SUBST; s++) {
|
||||
if (evalSet.contains(eval)) {
|
||||
// Cyclic resolution pattern detected. Return current expression.
|
||||
return eval;
|
||||
}
|
||||
evalSet.add(eval);
|
||||
match.reset(eval);
|
||||
if (!match.find()) {
|
||||
return eval;
|
||||
|
@ -1000,6 +1000,15 @@ public void testGetClassesShouldReturnEmptyArray()
|
||||
+ classes.length, 0, classes.length);
|
||||
}
|
||||
|
||||
public void testInvalidSubstitutation() {
|
||||
String key = "test.random.key";
|
||||
String keyExpression = "${" + key + "}";
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.set(key, keyExpression);
|
||||
String value = configuration.get(key);
|
||||
assertTrue("Unexpected value " + value, value.equals(keyExpression));
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
junit.textui.TestRunner.main(new String[]{
|
||||
TestConfiguration.class.getName()
|
||||
|
Loading…
Reference in New Issue
Block a user