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

check if a plugin has a executor service #1038

Merged
merged 2 commits into from
Aug 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public ExecutorService getExecutorService() {

return this.service;
}

public boolean hasExecutorService() {
return this.service != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
import com.velocitypowered.api.scheduler.Scheduler;
import com.velocitypowered.api.scheduler.TaskStatus;
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -116,17 +119,24 @@ public boolean shutdown() throws InterruptedException {
task.cancel();
}
timerExecutionService.shutdown();
for (final PluginContainer container : this.pluginManager.getPlugins()) {
final List<PluginContainer> plugins = new ArrayList<>(this.pluginManager.getPlugins());
final Iterator<PluginContainer> pluginIterator = plugins.iterator();
while (pluginIterator.hasNext()) {
final PluginContainer container = pluginIterator.next();
if (container instanceof VelocityPluginContainer) {
(container).getExecutorService().shutdown();
final VelocityPluginContainer pluginContainer = (VelocityPluginContainer) container;
if (pluginContainer.hasExecutorService()) {
container.getExecutorService().shutdown();
} else {
pluginIterator.remove();
}
} else {
pluginIterator.remove();
}
}

boolean allShutdown = true;
for (final PluginContainer container : this.pluginManager.getPlugins()) {
if (!(container instanceof VelocityPluginContainer)) {
continue;
}
for (final PluginContainer container : plugins) {
final String id = container.getDescription().getId();
final ExecutorService service = (container).getExecutorService();

Expand Down