metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmiklav...@apache.org
Subject metron git commit: METRON-1887: Add logging to the ClasspathFunctionResolver (mmiklavc via mmiklavc) closes apache/metron#1274
Date Mon, 26 Nov 2018 21:21:51 GMT
Repository: metron
Updated Branches:
  refs/heads/master e0f9b48e0 -> e1a957be3


METRON-1887: Add logging to the ClasspathFunctionResolver (mmiklavc via mmiklavc) closes apache/metron#1274


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

Branch: refs/heads/master
Commit: e1a957be3b44986799fb9672536bce43705bd6fa
Parents: e0f9b48
Author: mmiklavc <michael.miklavcic@gmail.com>
Authored: Mon Nov 26 14:21:15 2018 -0700
Committer: Michael Miklavcic <michael.miklavcic@gmail.com>
Committed: Mon Nov 26 14:21:15 2018 -0700

----------------------------------------------------------------------
 .../common/utils/VFSClassloaderUtil.java        |  4 +++
 .../resolver/ClasspathFunctionResolver.java     | 32 +++++++++++---------
 2 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/e1a957be/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/VFSClassloaderUtil.java
----------------------------------------------------------------------
diff --git a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/VFSClassloaderUtil.java
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/VFSClassloaderUtil.java
index 803398c..5690682 100644
--- a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/VFSClassloaderUtil.java
+++ b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/utils/VFSClassloaderUtil.java
@@ -112,14 +112,18 @@ public class VFSClassloaderUtil {
    * @throws FileSystemException
    */
   public static Optional<ClassLoader> configureClassloader(String paths) throws FileSystemException
{
+    LOG.debug("Configuring class loader with paths = {}", paths);
     if(paths.trim().isEmpty()) {
+      LOG.debug("No paths provided. Not returning a ClassLoader.");
       return Optional.empty();
     }
     FileSystemManager vfs = generateVfs();
     FileObject[] objects = resolve(vfs, paths);
     if(objects == null || objects.length == 0) {
+      LOG.debug("No Classloader able to be resolved from provided paths. Not returning a
ClassLoader.");
       return Optional.empty();
     }
+    LOG.debug("vfs = {}, objects = {}", vfs, objects);
     return Optional.of(new VFSClassLoader(objects, vfs, vfs.getClass().getClassLoader()));
   }
 

http://git-wip-us.apache.org/repos/asf/metron/blob/e1a957be/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java
----------------------------------------------------------------------
diff --git a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java
index b17233a..7b75009 100644
--- a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java
+++ b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java
@@ -18,6 +18,11 @@
 
 package org.apache.metron.stellar.dsl.functions.resolver;
 
+import static org.apache.metron.stellar.dsl.Context.Capabilities.STELLAR_CONFIG;
+import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_SEARCH_EXCLUDES_KEY;
+import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_SEARCH_INCLUDES_KEY;
+import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_VFS_PATHS;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -33,16 +38,9 @@ import org.apache.metron.stellar.common.utils.VFSClassloaderUtil;
 import org.apache.metron.stellar.dsl.Context;
 import org.apache.metron.stellar.dsl.Stellar;
 import org.apache.metron.stellar.dsl.StellarFunction;
-
-import org.atteo.classindex.ClassFilter;
 import org.atteo.classindex.ClassIndex;
 import org.reflections.util.FilterBuilder;
 
-import static org.apache.metron.stellar.dsl.Context.Capabilities.STELLAR_CONFIG;
-import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_SEARCH_EXCLUDES_KEY;
-import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_SEARCH_INCLUDES_KEY;
-import static org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.Config.STELLAR_VFS_PATHS;
-
 /**
  * Performs function resolution for Stellar by searching the classpath.
  *
@@ -239,17 +237,23 @@ public class ClasspathFunctionResolver extends BaseFunctionResolver
{
   public Set<Class<? extends StellarFunction>> resolvables() {
 
     ClassLoader[] cls = null;
-    if(this.classLoaders.size() == 0) {
+    if (this.classLoaders.size() == 0) {
       LOG.warn("Using System classloader");
-      cls = new ClassLoader[] { getClass().getClassLoader() };
-    }
-    else {
-      cls = new ClassLoader[this.classLoaders.size()];
+      cls = new ClassLoader[]{getClass().getClassLoader()};
+    } else {
+      List<ClassLoader> classLoaderList = new ArrayList<>();
       for (int i = 0; i < this.classLoaders.size(); ++i) {
         ClassLoader cl = this.classLoaders.get(i);
-        LOG.debug("Using classloader: "+ cl.getClass().getCanonicalName());
-        cls[i] = cl;
+        if (null != cl) {
+          LOG.debug("Using classloader: {}", cl.getClass().getCanonicalName());
+          classLoaderList.add(cl);
+        } else {
+          LOG.error(
+              "This should not happen, so report a bug if you see this error - Classloader
{} of {} was null. Classloader list is: {}",
+              i, this.classLoaders.size(), this.classLoaders);
+        }
       }
+      cls = classLoaderList.toArray(new ClassLoader[classLoaderList.size()]);
     }
 
     FilterBuilder filterBuilder = new FilterBuilder();


Mime
View raw message