Revert "Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5636)"
This reverts commit 20fc4ab700
.
This commit is contained in:
parent
20fc4ab700
commit
ecbf5a38e5
56 changed files with 232 additions and 210 deletions
|
@ -5,34 +5,40 @@ Subject: [PATCH] Make JavaPluginLoader thread-safe
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index f26303315c9c93356f0b04440136855dd54d32b7..ce751577623eaad0f31e2eb7bf0842d1ab73e845 100644
|
||||
index de44d850d7b3ab3e528eb6f2de375a6c3e0e5cf9..9d1f7cdf12029c8198792fd299f92be476040222 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -52,6 +52,8 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
public final class JavaPluginLoader implements PluginLoader {
|
||||
@@ -52,6 +52,8 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
final Server server;
|
||||
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
|
||||
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
|
||||
+ private final Map<String, java.util.concurrent.locks.ReentrantReadWriteLock> classLoadLock = new java.util.HashMap<String, java.util.concurrent.locks.ReentrantReadWriteLock>(); // Paper
|
||||
+ private final Map<String, Integer> classLoadLockCount = new java.util.HashMap<String, Integer>(); // Paper
|
||||
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
|
||||
private final LibraryLoader libraryLoader;
|
||||
|
||||
@@ -201,12 +203,33 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
/**
|
||||
@@ -191,7 +193,19 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
|
||||
@Nullable
|
||||
Class<?> getClassByName(final String name, boolean resolve, PluginDescriptionFile description) {
|
||||
Class<?> getClassByName(final String name) {
|
||||
+ // Paper start - make MT safe
|
||||
Class<?> cachedClass = classes.get(name);
|
||||
+ if (cachedClass != null) {
|
||||
+ return cachedClass;
|
||||
+ }
|
||||
+ java.util.concurrent.locks.ReentrantReadWriteLock lock;
|
||||
+ synchronized (classLoadLock) {
|
||||
+ lock = classLoadLock.computeIfAbsent(name, (x) -> new java.util.concurrent.locks.ReentrantReadWriteLock());
|
||||
+ classLoadLockCount.compute(name, (x, prev) -> prev != null ? prev + 1 : 1);
|
||||
+ }
|
||||
+ lock.writeLock().lock();try {
|
||||
+ cachedClass = classes.get(name);
|
||||
+ // Paper end
|
||||
for (PluginClassLoader loader : loaders) {
|
||||
try {
|
||||
return loader.loadClass0(name, resolve, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, loader.plugin.getDescription()));
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
|
||||
if (cachedClass != null) {
|
||||
return cachedClass;
|
||||
@@ -205,6 +219,19 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Paper start - make MT safe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue