Avoid ThreadLocal leak when using ReflectiveOperationContributor

Most OperationContributor implementations create an ObjectMethod that
points to themselves. That means that in their ObjectMethod.close()
call, we will be able to remove() the ThreadLocal objects.

However, ReflectiveOperationContributor creates an ObjectMethod with
a different target object, so ObjectMethod.close() won't be able to
help in that case. Fortunately, the ROC ObjectMethod objects have no
use for getTarget() / getContext() in the ROC anyway, so what we can
do is simply skip setTarget() and setContext() when the ObjectMethod
won't be using them (i.e. the reflection target is *not* the
ObjectContributor itself).
1 file changed