HADOOP-11309. System class pattern package.Foo should match package.Foo$Bar, too. Contributed by Gera Shegalov
This commit is contained in:
parent
7250b0bf91
commit
b4ca727690
@ -447,6 +447,9 @@ Release 2.7.0 - UNRELEASED
|
|||||||
HADOOP-11311. Restrict uppercase key names from being created with JCEKS.
|
HADOOP-11311. Restrict uppercase key names from being created with JCEKS.
|
||||||
(wang)
|
(wang)
|
||||||
|
|
||||||
|
HADOOP-11309. System class pattern package.Foo should match
|
||||||
|
package.Foo$Bar, too (Gera Shegalov via jlowe)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -228,13 +228,16 @@ public static boolean isSystemClass(String name, List<String> systemClasses) {
|
|||||||
c = c.substring(1);
|
c = c.substring(1);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
if (c.endsWith(".") && canonicalName.startsWith(c)) {
|
if (canonicalName.startsWith(c)) {
|
||||||
return result;
|
if ( c.endsWith(".") // package
|
||||||
} else if (canonicalName.equals(c)) {
|
|| canonicalName.length() == c.length() // class
|
||||||
|
|| canonicalName.length() > c.length() // nested
|
||||||
|
&& canonicalName.charAt(c.length()) == '$' ) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -90,15 +90,27 @@ public void testConstructUrlsFromClasspath() throws Exception {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsSystemClass() {
|
public void testIsSystemClass() {
|
||||||
assertFalse(isSystemClass("org.example.Foo", null));
|
testIsSystemClassInternal("");
|
||||||
assertTrue(isSystemClass("org.example.Foo", classes("org.example.Foo")));
|
}
|
||||||
assertTrue(isSystemClass("/org.example.Foo", classes("org.example.Foo")));
|
|
||||||
assertTrue(isSystemClass("org.example.Foo", classes("org.example.")));
|
@Test
|
||||||
assertTrue(isSystemClass("net.example.Foo",
|
public void testIsSystemNestedClass() {
|
||||||
|
testIsSystemClassInternal("$Klass");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testIsSystemClassInternal(String nestedClass) {
|
||||||
|
assertFalse(isSystemClass("org.example.Foo" + nestedClass, null));
|
||||||
|
assertTrue(isSystemClass("org.example.Foo" + nestedClass,
|
||||||
|
classes("org.example.Foo")));
|
||||||
|
assertTrue(isSystemClass("/org.example.Foo" + nestedClass,
|
||||||
|
classes("org.example.Foo")));
|
||||||
|
assertTrue(isSystemClass("org.example.Foo" + nestedClass,
|
||||||
|
classes("org.example.")));
|
||||||
|
assertTrue(isSystemClass("net.example.Foo" + nestedClass,
|
||||||
classes("org.example.,net.example.")));
|
classes("org.example.,net.example.")));
|
||||||
assertFalse(isSystemClass("org.example.Foo",
|
assertFalse(isSystemClass("org.example.Foo" + nestedClass,
|
||||||
classes("-org.example.Foo,org.example.")));
|
classes("-org.example.Foo,org.example.")));
|
||||||
assertTrue(isSystemClass("org.example.Bar",
|
assertTrue(isSystemClass("org.example.Bar" + nestedClass,
|
||||||
classes("-org.example.Foo.,org.example.")));
|
classes("-org.example.Foo.,org.example.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user