diff --git a/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch b/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch index a6febb4a55..286554f802 100644 --- a/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch +++ b/Spigot-API-Patches/Make-JavaPluginLoader-thread-safe.patch @@ -5,7 +5,7 @@ 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 8ff228ce..c0884f27 100644 +index 8ff228ce..ba2c5c6e 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { @@ -22,16 +22,21 @@ index 8ff228ce..c0884f27 100644 @Nullable 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 - Class cachedClass = classes.get(name); if (cachedClass != null) { + return cachedClass; @@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader { } } diff --git a/Spigot-Server-Patches/Reduce-Either-Optional-allocation.patch b/Spigot-Server-Patches/Reduce-Either-Optional-allocation.patch index a211e086fe..9d666e1120 100644 --- a/Spigot-Server-Patches/Reduce-Either-Optional-allocation.patch +++ b/Spigot-Server-Patches/Reduce-Either-Optional-allocation.patch @@ -7,7 +7,7 @@ In order to get chunk values, we shouldn't need to create an optional each time. diff --git a/src/main/java/com/mojang/datafixers/util/Either.java b/src/main/java/com/mojang/datafixers/util/Either.java -index a90adac7b..efae74b71 100644 +index a90adac7b..4bb621d57 100644 --- a/src/main/java/com/mojang/datafixers/util/Either.java +++ b/src/main/java/com/mojang/datafixers/util/Either.java @@ -0,0 +0,0 @@ public abstract class Either implements App, L> { @@ -19,7 +19,7 @@ index a90adac7b..efae74b71 100644 public Left(final L value) { - this.value = value; -+ this.value = value; this.valueOptional = Optional.of(value); // Paper - reduce the optional allocation... ++ this.value = value; this.valueOptional = value != null ? Optional.of(value) : Optional.empty(); // Paper - reduce the optional allocation... } @Override @@ -41,7 +41,7 @@ index a90adac7b..efae74b71 100644 public Right(final R value) { - this.value = value; -+ this.value = value; this.valueOptional = Optional.of(value); // Paper - reduce the optional allocation... ++ this.value = value; this.valueOptional = value != null ? Optional.of(value) : Optional.empty(); // Paper - reduce the optional allocation... } @Override