Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-10579: Upgrade reflections from 0.9.12 to 0.10.2 #14029

Merged
merged 2 commits into from Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
gharris1727 marked this conversation as resolved.
Show resolved Hide resolved
reload4j: "1.2.25",
rocksDB: "7.1.2",
scalaCollectionCompat: "2.10.0",
Expand Down