3

Closed

EventBus Interface Method Cache

description

The DefaultOrchardEventBus uses the Event class name interface name combination as the key for caching the interface method used when despatching messages to event classes.

The result can be a mis-match when trying to invoke the method - the interface from the cache and that of the class do not necessarily match - only by name.

Can be fixed by using the interface name plus namespace as the key for caching rather than rely on the class name interface name to be correctly unique.

Orchard\Events\DefaultOrchardEventBus.cs - TryInvokeMethod

//MethodInfo method = interfaceMethodsCache.GetOrAdd(String.Concat(eventHandler.GetType().Name + "" + interfaceType.Name, "_", methodName, "_", String.Join("_", arguments.Keys)), GetMatchingMethod(eventHandler, interfaceType, methodName, arguments));
MethodInfo method = interfaceMethodsCache.GetOrAdd(String.Concat(interfaceType.FullName, "", methodName, "_", String.Join("_", arguments.Keys)), GetMatchingMethod(eventHandler, interfaceType, methodName, arguments));

Will also remove duplicate interface methods that are currently cached.
Closed Sep 19, 2012 at 7:33 PM by sebastienros
Already fixed with #18933

comments

AimOrchard wrote Aug 9, 2012 at 8:04 AM

I think I ran into a related issue before.