Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
928bcc8d3a
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 09943450 Update SnakeYAML version 5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc 6f82b381 PR-788: Add getHand() to all relevant events CraftBukkit Changes: aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe 5329dd6fd PR-1107: Add getHand() to all relevant events 93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
54 Zeilen
2.7 KiB
Diff
54 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Trigary <trigary0@gmail.com>
|
|
Date: Wed, 15 Apr 2020 01:24:55 -0400
|
|
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 e98934d32b8dac88b3c3fd14ea5d726872212807..cf809eda2a3feb6abccf7286068280f430452135 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 {
|
|
final Server server;
|
|
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
|
|
+ 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 {
|
|
|
|
@Nullable
|
|
Class<?> getClassByName(final String name, boolean resolve, PluginDescriptionFile description) {
|
|
+ // Paper start - make MT safe
|
|
+ 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 {
|
|
+ // Paper end
|
|
for (PluginClassLoader loader : loaders) {
|
|
try {
|
|
return loader.loadClass0(name, resolve, false, ((SimplePluginManager) server.getPluginManager()).isTransitiveDepend(description, loader.plugin.getDescription()));
|
|
} catch (ClassNotFoundException cnfe) {
|
|
}
|
|
}
|
|
+ // Paper start - make MT safe
|
|
+ } finally {
|
|
+ synchronized (classLoadLock) {
|
|
+ lock.writeLock().unlock();
|
|
+ if (classLoadLockCount.get(name) == 1) {
|
|
+ classLoadLock.remove(name);
|
|
+ classLoadLockCount.remove(name);
|
|
+ } else {
|
|
+ classLoadLockCount.compute(name, (x, prev) -> prev - 1);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
return null;
|
|
}
|
|
|