Skip to content

Commit

Permalink
[FLINK-16222][core] Relax Plugin bounded type parameter constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
afedulov authored and zentol committed Mar 27, 2020
1 parent a0ea5e9 commit 4308e0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.util.ArrayUtils;
import org.apache.flink.util.ChildFirstClassLoader;
import org.apache.flink.util.TemporaryClassLoaderContext;

import javax.annotation.concurrent.ThreadSafe;
Expand All @@ -35,7 +34,7 @@

/**
* A {@link PluginLoader} is used by the {@link PluginManager} to load a single plugin. It is essentially a combination
* of a {@link ChildFirstClassLoader} and {@link ServiceLoader}. This class can locate and load service implementations
* of a {@link PluginClassLoader} and {@link ServiceLoader}. This class can locate and load service implementations
* from the plugin for a given SPI. The {@link PluginDescriptor}, which among other information contains the resource
* URLs, is provided at construction.
*/
Expand Down Expand Up @@ -69,7 +68,7 @@ public static PluginLoader create(PluginDescriptor pluginDescriptor, ClassLoader
* @param <P> Type of the requested plugin service.
* @return An iterator of all implementations of the given service interface that could be loaded from the plugin.
*/
public <P extends Plugin> Iterator<P> load(Class<P> service) {
public <P> Iterator<P> load(Class<P> service) {
try (TemporaryClassLoaderContext ignored = TemporaryClassLoaderContext.of(pluginClassLoader)) {
return new ContextClassLoaderSettingIterator<>(
ServiceLoader.load(service, pluginClassLoader).iterator(),
Expand All @@ -83,7 +82,7 @@ public <P extends Plugin> Iterator<P> load(Class<P> service) {
*
* @param <P> type of the iterated plugin element.
*/
static class ContextClassLoaderSettingIterator<P extends Plugin> implements Iterator<P> {
static class ContextClassLoaderSettingIterator<P> implements Iterator<P> {

private final Iterator<P> delegate;
private final ClassLoader pluginClassLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public PluginManager(Collection<PluginDescriptor> pluginDescriptors, ClassLoader
* @param <P> Type of the requested plugin service.
* @return Iterator over all implementations of the given service that could be loaded from all known plugins.
*/
public <P extends Plugin> Iterator<P> load(Class<P> service) {
public <P> Iterator<P> load(Class<P> service) {
ArrayList<Iterator<P>> combinedIterators = new ArrayList<>(pluginDescriptors.size());
for (PluginDescriptor pluginDescriptor : pluginDescriptors) {
PluginLoader pluginLoader = PluginLoader.create(pluginDescriptor, parentClassLoader, alwaysParentFirstPatterns);
Expand Down

0 comments on commit 4308e0c

Please sign in to comment.