Well, mike was right about deadlocks.

This commit is contained in:
md_5 2013-01-25 11:35:20 +11:00
parent 33ac93e0ae
commit cc5229ad6d
1 changed files with 4 additions and 28 deletions

View File

@ -1,14 +1,14 @@
From a62dabb02fe7405059ceb42495ed5dbc9704c1ea Mon Sep 17 00:00:00 2001
From e713a9083b0802334d046915c9f1995326e8956c Mon Sep 17 00:00:00 2001
From: snowleo <schneeleo@gmail.com>
Date: Wed, 17 Oct 2012 22:30:45 +0200
Subject: [PATCH] Make the plugin class loader thread safe
---
.../org/bukkit/plugin/java/JavaPluginLoader.java | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index 10fc26a..f9a09ef 100644
index 10fc26a..4dca063 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -45,6 +45,7 @@ import org.bukkit.plugin.UnknownDependencyException;
@ -36,30 +36,6 @@ index 10fc26a..f9a09ef 100644
/**
* @deprecated Internal field that wasn't intended to be exposed
*/
@@ -293,14 +294,16 @@ public class JavaPluginLoader implements PluginLoader {
if (cachedClass != null) {
return cachedClass;
} else {
- for (String current : loaders0.keySet()) {
- PluginClassLoader loader = loaders0.get(current);
+ synchronized (loaders) {
+ for (String current : loaders0.keySet()) {
+ PluginClassLoader loader = loaders0.get(current);
- try {
- cachedClass = loader.extended ? loader.findClass(name, false) : loader.findClass0(name, false); // Don't warn on deprecation, but maintain overridability
- } catch (ClassNotFoundException cnfe) {}
- if (cachedClass != null) {
- return cachedClass;
+ try {
+ cachedClass = loader.extended ? loader.findClass(name, false) : loader.findClass0(name, false); // Don't warn on deprecation, but maintain overridability
+ } catch (ClassNotFoundException cnfe) {}
+ if (cachedClass != null) {
+ return cachedClass;
+ }
}
}
}
--
1.8.1-rc2