Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/985#discussion_r180753753 --- Diff: metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/ClasspathFunctionResolver.java --- @@ -254,18 +266,24 @@ public void initialize(Context context) { Set<String> classes = new HashSet<>(); Set<Class<? extends StellarFunction>> ret = new HashSet<>(); for(ClassLoader cl : cls) { - for(Class<?> c : ClassIndex.getAnnotated(Stellar.class, cl)) { - LOG.debug("{}: Found class: {}", cl.getClass().getCanonicalName(), c.getCanonicalName()); - boolean isAssignable = StellarFunction.class.isAssignableFrom(c); - boolean isFiltered = filterBuilder.apply(c.getCanonicalName()); - if( isAssignable && isFiltered ) { - String className = c.getName(); - if(!classes.contains(className)) { - LOG.debug("{}: Added class: {}", cl.getClass().getCanonicalName(), className); - ret.add((Class<? extends StellarFunction>) c); - classes.add(className); + for(Class<?> c : getStellarClasses(cl)) { + try { + LOG.debug("{}: Found class: {}", cl.getClass().getCanonicalName(), c.getCanonicalName()); + if (includeClass(c, filterBuilder)) { + String className = c.getName(); + if (!classes.contains(className)) { + LOG.debug("{}: Added class: {}", cl.getClass().getCanonicalName(), className); + ret.add((Class<? extends StellarFunction>) c); + classes.add(className); + } } } + catch(Error le) { + //we have had some error loading a stellar function. This could mean that + //the classpath is unstable (e.g. old copies of jars are on the classpath). + LOG.error("Skipping class: " + le.getMessage() --- End diff -- ```java /** * <p>Gets the canonical class name for a {@code Class}.</p> * * @param cls the class for which to get the canonical class name; may be null * @return the canonical name of the class, or the empty String * @since 3.7 * @see Class#getCanonicalName() */ public static String getCanonicalName(final Class<?> cls) { return getCanonicalName(cls, StringUtils.EMPTY); } ``` This is in latest commons-lang. getCanonicalName returns null or the name. In either the function or the class function.
---