[
https://issues.apache.org/jira/browse/CAMEL-19828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17781849#comment-17781849
]
Ken Stevens commented on CAMEL-19828:
-------------------------------------
Here's a PR with a test and the fix:
https://github.com/apache/camel/pull/11882
> camel-twilio: conversion to PhoneNumber, .. fails after recent general
> converter change
> ---------------------------------------------------------------------------------------
>
> Key: CAMEL-19828
> URL: https://issues.apache.org/jira/browse/CAMEL-19828
> Project: Camel
> Issue Type: Bug
> Components: camel-core, camel-twilio
> Affects Versions: 4.x
> Reporter: Jiri Ondrusek
> Assignee: Jiri Ondrusek
> Priority: Minor
>
> When adopting the latest Camel into camel-quarkus I noticed an error.
> {code:java}
> NoTypeConversionAvailableException: No type converter available to convert
> from type: java.lang.String to the required type: com.twilio.type.Endpoint
> {code}
> Problem is caused by this change:
> [https://github.com/apache/camel/pull/11225/commits/e4007f2b1dfc982e5ea6a45427cbec8835ea58a5]
> As you can see
> [here|https://github.com/apache/camel/blob/main/components/camel-twilio/src/main/java/org/apache/camel/component/twilio/TwilioConverter.java],
> 2 converters are registered (i.e. String -> PhoneNumber). Unfortunately the
> Twilio API uses common interface `com.twilio.type.Endpoint`. See this
> [line|https://github.com/apache/camel/blob/main/components/camel-twilio/src/generated/java/org/apache/camel/component/twilio/CallEndpointConfiguration.java#L27].
> Therefore the mechanism for selection converters is not able to find
> converter `String -> Endpoint`.
> The behavior could be simply tested by following code added into
> `TwilioEndpointTest`:
> {code:java}
> te = context.getEndpoint(
>
> "twilio://call/create?from=RAW(+15005550006)&to=RAW(+14108675310)&url=http://demo.twilio.com/docs/voice.xml",
> TwilioEndpoint.class);
> Assertions.assertTrue(te.getConfiguration() instanceof
> CallEndpointConfiguration);
> CallEndpointConfiguration cee = (CallEndpointConfiguration)
> te.getConfiguration();
> Assertions.assertEquals("+15005550006", cee.getFrom().getEndpoint());
> Assertions.assertEquals("+14108675310", cee.getTo().getEndpoint());
> {code}
> I'm not sure how it was possible, but the test wold succeed before the change
> introduced by e4007f2b1dfc982e5ea6a45427cbec8835ea58a5.
> I think that the conversion before the change might not be correct in this
> twilio case (the conversion was probably possible because of the fallback
> conversion and was depending on the order of the registered converters - I
> don't see a way how to decide which conversion should be used `PhoneNumber`
> or `Sip` from the registered converters from the link above)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)