Hi,
using the following auto-generated classes (Class1, Class2) causes an
AmbiguousMethodCallException in a unit test, although the mentioned methods are
not ambiguous. Class1 looks like this:
@javax.annotation.Generated…
public class Class1 {
@JsonProperty("data")
private Class2 data = null;
public Class1 data(Class2 data) {
this.data = data;
return this;
}
public Class2 getData() {
return data;
}
public void setData(Class2 data) {
this.data = data;
}
}
I did not find a way to get rid of the auto-generated method “public Class1
data(Class2 data)”, so I checked why this exception is thrown in Camel.
org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous method
invocations possible:
public Class2 Class1.getData()
public Class1 Class1.data(Class2)
Obviously these two methods have different return types and different
parameters, so there should not be an ambiguous method invocation possible here.
I think the problem is in class org.apache.camel.component.bean.BeanInfo in the
following method:
private List<MethodInfo> getOperations(String methodName) {
// do not use qualifier for name
if (methodName.contains("(")) {
methodName = StringHelper.before(methodName, "(");
}
List<MethodInfo> answer = operations.get(methodName);
if (answer != null) {
return answer;
}
// now try all getters to see if any of those matched the methodName
for (Method method : methodMap.keySet()) {
if (isGetter(method)) {
String shorthandMethodName = getGetterShorthandName(method);
// if the two names matches then see if we can find it using
that name
if (methodName != null &&
methodName.equals(shorthandMethodName)) {
return operations.get(method.getName());
}
}
}
return null;
}
Here, the method “data” is mapped to the (already known) method “getData”
without considering return values or parameters of these methods (only the name
is compared).
BR,
Manuel
Sollten Sie diese E-Mail unbeabsichtigt bzw. irrtümlich erhalten haben, so
weisen wir Sie darauf hin, dass gemäß § 161 Abs 4 TKG 2021 der Inhalt sowie die
Tatsache des Empfangs dieser E-Mail weder aufgezeichnet noch verwertet oder
Unbefugten mitgeteilt werden dürfen. Wir ersuchen Sie, die Nachricht von Ihrem
System zu löschen und sich mit uns in Verbindung zu setzen. If you have
received this email accidentally or in error, we point out that, in accordance
with § 161 para. 4 TKG 2021 (Telecommunications Act), the contents of this
email and the fact of its receipt must not be recorded, exploited or
communicated to unauthorized persons. We ask you to delete the message from
your system and to contact us.
Allgemein | General
Manuel LANGER
im Auftrag von
[SPAR Business Services GmbH]<http://www.spar-ics.com>
SPAR Business Services GmbH
Information & Communication Services
Europastrasse 3, 5015 Salzburg, Austria
FN 68396 h
Mobile: +43 664 8833 8301
E-Mail: [email protected]<mailto:[email protected]>
Internet: http://www.spar.at<http://>