Fixing dispatching of indexed parameter req #323
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for
ParameterMessageBehavior
when setting indexed parameters. When an Agent has a defined setter methodsetMyParam(int ndx, Object value)
, theParameterMessageBehavior
can't find the method.I traced this down to Apache Commons Lang.
ParameterMessageBehavior
callsinvokeCompatibleSetter
which then callsMethodUtils.invokeMethod(agent, name, ndx, value)
, wherename
is the method name (setMyParam
in our example),ndx
is the parameter index andvalue
is the value to be set.While doing the reflection MethodUtils does a
ClassUtils.toClass(args)
on the list of all args. That converts theint ndx
into a boxedInteger
. Because of this, looks ups of indexed setters can fail since they're commonly defined with the index being anint
.This fix tries to detect that and tries to use the standard Java reflection API (
Class.getMethod
) to find an appropriate method to dispatch to.