[testng] 21/355: Only load the XmlClass once from one ClassLoader

Eugene Zhukov eugene-guest at moszumanska.debian.org
Tue Aug 18 10:19:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.

commit f05a3af7797aa441152a3e5daa1bf566010f84cb
Author: Aslak Knutsen <aslak at redhat.com>
Date:   Wed Aug 14 16:20:43 2013 +0200

    Only load the XmlClass once from one ClassLoader
    
    XmlClass.getSupportClass uses the Thread Context ClassLoader,
    while Class.forName use the Callers ClassLoader. These might
    not be the same ClassLoader. Previous versions used the TCCL.
---
 .../java/org/testng/internal/XmlMethodSelector.java    | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/testng/internal/XmlMethodSelector.java b/src/main/java/org/testng/internal/XmlMethodSelector.java
index 2661987..5dc419b 100755
--- a/src/main/java/org/testng/internal/XmlMethodSelector.java
+++ b/src/main/java/org/testng/internal/XmlMethodSelector.java
@@ -235,28 +235,22 @@ public class XmlMethodSelector implements IMethodSelector {
     return className + "." + methodName;
   }
 
-  private void checkMethod(String className, String methodName) {
+  private void checkMethod(Class<?> c, String methodName) {
     Pattern p = Pattern.compile(methodName);
-    try {
-      Class<?> c = Class.forName(className);
-      for (Method m : c.getMethods()) {
-        if (p.matcher(m.getName()).matches()) {
-          return;
-        }
+    for (Method m : c.getMethods()) {
+      if (p.matcher(m.getName()).matches()) {
+        return;
       }
-    } catch (ClassNotFoundException e) {
-      throw new TestNGException(e);
     }
-
     Utils.log("Warning", 2, "The regular expression \"" + methodName + "\" didn't match any" +
-    		" method in class " + className);
+              " method in class " + c.getName());
   }
 
   public void setXmlClasses(List<XmlClass> classes) {
     m_classes = classes;
     for (XmlClass c : classes) {
       for (XmlInclude m : c.getIncludedMethods()) {
-        checkMethod(c.getName(), m.getName());
+        checkMethod(c.getSupportClass(), m.getName());
         String methodName = makeMethodName(c.getName(), m.getName());
         m_includedMethods.put(methodName, m);
       }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git



More information about the pkg-java-commits mailing list