Skip to content

Commit

Permalink
KAFKA-10579: Upgrade reflections from 0.9.12 to 0.10.2 (apache#14029)
Browse files Browse the repository at this point in the history
Reviewers: Divij Vaidya <diviv@amazon.com>, Chris Egerton <chris.egerton@aiven.io>
  • Loading branch information
gharris1727 authored and jeqo committed Aug 15, 2023
1 parent 8e9ba92 commit e0670e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
3 changes: 2 additions & 1 deletion LICENSE-binary
Expand Up @@ -251,6 +251,7 @@ netty-transport-classes-epoll-4.1.94.Final
netty-transport-native-epoll-4.1.94.Final
netty-transport-native-unix-common-4.1.94.Final
plexus-utils-3.3.0
reflections-0.10.2
reload4j-1.2.25
rocksdbjni-7.1.2
scala-collection-compat_2.13-2.10.0
Expand Down Expand Up @@ -329,4 +330,4 @@ paranamer-2.8, see: licenses/paranamer-BSD-3-clause
Do What The F*ck You Want To Public License
see: licenses/DWTFYWTPL

reflections-0.9.12
reflections-0.10.2
Expand Up @@ -25,15 +25,13 @@
import org.apache.kafka.connect.storage.HeaderConverter;
import org.apache.kafka.connect.transforms.Transformation;
import org.apache.kafka.connect.transforms.predicates.Predicate;
import org.reflections.Configuration;
import org.reflections.Reflections;
import org.reflections.ReflectionsException;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.Scanners;
import org.reflections.util.ConfigurationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URL;
import java.util.Collections;
import java.util.ServiceLoader;
import java.util.Set;
Expand Down Expand Up @@ -79,9 +77,9 @@ protected PluginScanResult scanPlugins(PluginSource source) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setClassLoaders(new ClassLoader[]{loader});
builder.addUrls(source.urls());
builder.setScanners(new SubTypesScanner());
builder.useParallelExecutor();
Reflections reflections = new InternalReflections(builder);
builder.setScanners(Scanners.SubTypes);
builder.setParallel(true);
Reflections reflections = new Reflections(builder);

return new PluginScanResult(
getPluginDesc(reflections, SinkConnector.class, loader),
Expand Down Expand Up @@ -139,25 +137,4 @@ private <T> SortedSet<PluginDesc<T>> getPluginDesc(
}
return result;
}

private static class InternalReflections extends Reflections {

public InternalReflections(Configuration configuration) {
super(configuration);
}

// When Reflections is used for parallel scans, it has a bug where it propagates ReflectionsException
// as RuntimeException. Override the scan behavior to emulate the singled-threaded logic.
@Override
protected void scan(URL url) {
try {
super.scan(url);
} catch (ReflectionsException e) {
Logger log = Reflections.log;
if (log != null && log.isWarnEnabled()) {
log.warn("could not create Vfs.Dir from url. ignoring the exception and continuing", e);
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Expand Up @@ -131,7 +131,7 @@ versions += [
netty: "4.1.94.Final",
pcollections: "4.0.1",
powermock: "2.0.9",
reflections: "0.9.12",
reflections: "0.10.2",
reload4j: "1.2.25",
rocksDB: "7.1.2",
scalaCollectionCompat: "2.10.0",
Expand Down

0 comments on commit e0670e7

Please sign in to comment.