Bukkit/Bukkit — pull request #693 by snowleo (2012-10-17 20:39:27+00:00)
Title: Thread-safety of Plugin Class Loader

If a plugin is enable / disabled, while another thread requests a class from the class loader, the current implementation throws ConcurrentModificationExceptions sometimes. The class loader should be thread safe.

Here is an example of a CME:

Caused by: java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(Unknown Source)
at java.util.LinkedHashMap$KeyIterator.next(Unknown Source)
at org.bukkit.plugin.java.JavaPluginLoader.getClassByName(JavaPluginLoader.java:234)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:40)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
...

This pull request contains the necessary fixes to make the PluginClassLoader thread safe.