tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject [10/24] tomee git commit: TOMEE-1640 prevent not loadable bean classes to be seen by CDI - and fail later in extensions
Date Mon, 02 Nov 2015 17:15:04 GMT
TOMEE-1640 prevent not loadable bean classes to be seen by CDI - and fail later in extensions


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

Branch: refs/heads/tomee-7.0.0-M1
Commit: 938c6f8566f9cea882266e8b08b8d373cc04a9a6
Parents: 009b7f8
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Wed Oct 21 17:58:18 2015 +0200
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Wed Oct 21 17:58:18 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/openejb/cdi/CdiScanner.java    | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/938c6f85/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
index 27e2ac0..b20e56d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
@@ -70,10 +70,15 @@ public class CdiScanner implements ScannerService {
     private final Set<Class<?>> classes = new HashSet<>();
     private final Set<Class<?>> startupClasses = new HashSet<>();
     private final Set<URL> beansXml = new HashSet<>();
+    private final boolean logDebug;
 
     private WebBeansContext webBeansContext;
     private ClassLoader containerLoader;
 
+    public CdiScanner() {
+        logDebug = "true".equals(SystemInstance.get().getProperty("openejb.cdi.noclassdeffound.log",
"false"));
+    }
+
     public void setContext(final WebBeansContext webBeansContext) {
         this.webBeansContext = webBeansContext;
     }
@@ -313,14 +318,24 @@ public class CdiScanner implements ScannerService {
      */
     private Class load(final String className, final ClassLoader classLoader) {
         try {
-            return classLoader.loadClass(className);
+            final Class<?> loadClass = classLoader.loadClass(className);
+            tryToMakeItFail(loadClass);
+            return loadClass;
         } catch (final ClassNotFoundException e) {
             return null;
         } catch (final NoClassDefFoundError e) {
+            if (logDebug) {
+                Logger.getInstance(LogCategory.OPENEJB_CDI, CdiScanner.class).warning(className
+ " -> " + e);
+            }
             return null;
         }
     }
 
+    private void tryToMakeItFail(final Class<?> loadClass) { // we try to avoid later
NoClassDefFoundError
+        loadClass.getDeclaredFields();
+        loadClass.getDeclaredMethods();
+    }
+
     @Override
     public void scan() {
         // Unused


Mime
View raw message