Events: Allow same event type to be re-registered

When an event type is registered, an exception is raised if the given
event type is already registered.

This has the unfortunate side-effect that if a plugin registers any
event types, that plugin cannot be reloaded. The reason is that when
a plugin is unloaded, its registered events are not unregistered.

As a workaround for this, simply remove the check for duplicate event
types. Long term we will need to find a way to make plugins remove
their events from the list on unload.

Bug: Issue 3301
Change-Id: I85e24f79ea4c901d5141dc9530dff0dc51ff4976
This commit is contained in:
David Pursehouse
2015-04-16 09:49:40 +09:00
parent 8cca1a4592
commit eabc8ad389

View File

@@ -40,15 +40,10 @@ public class EventTypes {
/** Register an event.
*
* @param event The event to register.
* @throws IllegalArgumentException if the event's type is already
* registered.
**/
public static void registerClass(Event event) {
String type = event.getType();
if (typesByString.containsKey(type)) {
throw new IllegalArgumentException(
"Event type already registered: " + type);
}
typesByString.put(type, event.getClass());
}