hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject hadoop git commit: HADOOP-11309. System class pattern package.Foo should match package.Foo$Bar, too. Contributed by Gera Shegalov
Date Tue, 18 Nov 2014 17:23:33 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 7250b0bf9 -> b4ca72769


HADOOP-11309. System class pattern package.Foo should match package.Foo$Bar, too. Contributed
by Gera Shegalov


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

Branch: refs/heads/trunk
Commit: b4ca7276902ad362f746ea997f7e977a7a6abd0e
Parents: 7250b0b
Author: Jason Lowe <jlowe@apache.org>
Authored: Tue Nov 18 17:22:21 2014 +0000
Committer: Jason Lowe <jlowe@apache.org>
Committed: Tue Nov 18 17:22:21 2014 +0000

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 +++
 .../hadoop/util/ApplicationClassLoader.java     | 11 ++++++---
 .../hadoop/util/TestApplicationClassLoader.java | 26 ++++++++++++++------
 3 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b4ca7276/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index e4cc8e7..7fc29a6 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -447,6 +447,9 @@ Release 2.7.0 - UNRELEASED
     HADOOP-11311. Restrict uppercase key names from being created with JCEKS.
     (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
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b4ca7276/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
index b18997c..d2ab015 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
@@ -228,10 +228,13 @@ public class ApplicationClassLoader extends URLClassLoader {
           c = c.substring(1);
           result = false;
         }
-        if (c.endsWith(".") && canonicalName.startsWith(c)) {
-          return result;
-        } else if (canonicalName.equals(c)) {
-          return result;
+        if (canonicalName.startsWith(c)) {
+          if (   c.endsWith(".")                                   // package
+              || canonicalName.length() == c.length()              // class
+              ||    canonicalName.length() > c.length()            // nested
+                 && canonicalName.charAt(c.length()) == '$' ) {
+            return result;
+          }
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b4ca7276/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestApplicationClassLoader.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestApplicationClassLoader.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestApplicationClassLoader.java
index 5d0e131..cc16493 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestApplicationClassLoader.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestApplicationClassLoader.java
@@ -90,15 +90,27 @@ public class TestApplicationClassLoader {
   
   @Test
   public void testIsSystemClass() {
-    assertFalse(isSystemClass("org.example.Foo", null));
-    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.")));
-    assertTrue(isSystemClass("net.example.Foo",
+    testIsSystemClassInternal("");
+  }
+
+  @Test
+  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.")));
-    assertFalse(isSystemClass("org.example.Foo",
+    assertFalse(isSystemClass("org.example.Foo" + nestedClass,
         classes("-org.example.Foo,org.example.")));
-    assertTrue(isSystemClass("org.example.Bar",
+    assertTrue(isSystemClass("org.example.Bar" + nestedClass,
         classes("-org.example.Foo.,org.example.")));
   }
   


Mime
View raw message