-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)
Description
getMethodArgumentValues() performs early argument resolution by type; even when parameters are annotated and should be resolved by the resolvers.
@Test
void testInvocableHandlerMethod() throws Exception {
TestClass bean = new TestClass();
InvocableHandlerMethod handler = messageHandlerFactory().createInvocableHandlerMethod(bean,
TestClass.class.getDeclaredMethod("defMethod", Object.class, String.class));
handler.invoke(new GenericMessage<>("foo", Collections.singletonMap("bar", "baz")), "foo");
assertThat(bean.object).isEqualTo("foo");
assertThat(bean.bar).isEqualTo("baz");
}
private MessageHandlerMethodFactory messageHandlerFactory() {
DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
DefaultFormattingConversionService cs = new DefaultFormattingConversionService();
defaultFactory.setConversionService(cs);
GenericMessageConverter messageConverter = new GenericMessageConverter(cs);
defaultFactory.setMessageConverter(messageConverter);
defaultFactory.afterPropertiesSet();
return defaultFactory;
}
public static class TestClass {
Object object;
String bar;
public void defMethod(Object obj, @Header("bar") String bar) {
this.object = obj;
this.bar = bar;
}
}Both parameters are resolved via the providedArgs (foo, foo).
Manifested in this Spring for Apache Kafka issue.
I can probably work around it in spring-kafka by subclassing and overriding to ignore parameters with findProvidedArgument() @Header annotations, but thought I should raise it here because the same issue would apply to other messaging apps.
Oops - findProvidedArgument is static, and I can't override getMethodArgumentValues because it uses private fields.
Metadata
Metadata
Assignees
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)