CallHandler contract

Topics: Development Team Discussion
Aug 15, 2007 at 3:13 PM
Let's take CachingCallHandler as an example. It caches return values of methods.

At runtime, it will check whether or not the method returns something (ReturnType != typeof(void)). I was wondering if it should throw when a method is passed that has a void return type instead of just forwarding to the next handler?

After all, this handler has been setup with "wrong" matching rules and it gives the user the impression that caching might be occuring when it's not.

The same way I am about to check-in a OneWayCallHandler that only works with void-return methods. I am wondering whether I should throw or just forward to the next handler.
Aug 15, 2007 at 11:33 PM
IIRC, the reason the CachingCallHandler does not throw is because when you use a type machingrule, this type would not be able to have methods that return Void... or atleast calling these methods would not be possible, becuase of the exception thrown.

Similarly, if you would have a OneWayCallHandler (which i think is a great idea!) i'd say it should not throw either and pass execution. Since otherwise this callhandler would make it inpractical match on type (or something even more course grained).

Aug 16, 2007 at 4:44 AM
One way around would have been to define a more complex rule:

For OneWayCallHandler:

**TypeMatchingRule ( typeof(Foo) )
**ReturnTypeMatchingRule ( typeof(void) )

But then again, since matching rules apply to all handlers withing a policy, it could become difficult to use such CallHandler in conjunction with others within a Policy since their respective MatchinRules may be different.