camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-11235) Simple Language: Set#size fails with AmbiguousMethodCallException
Date Mon, 08 May 2017 08:26:04 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-11235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16000428#comment-16000428
] 

Pascal Schumacher commented on CAMEL-11235:
-------------------------------------------

Sorry, I missed that the problem does not seem to occur with java.util collections. But it
occurs for guava collections (which are pretty wildly used imho).

To reproduce use:

{code:xml}
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>21.0</version>
</dependency>
{code}

{code:java}
public class AmbiguousMethodCallExceptionTest extends CamelTestSupport {

    public static class AmbiguousMethodCallExceptionRoute extends RouteBuilder {

        @Override
        public void configure() throws Exception {
            from("seda:in").choice().when(simple("${headers.set.size} != 0")).to("mock:out");
        }
    }

    @Produce(uri = "seda:in")
    private ProducerTemplate in;

    @EndpointInject(uri = "mock:out")
    private MockEndpoint out;

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new AmbiguousMethodCallExceptionRoute();
    }

    @Test
    public void ambiguousMethodCallException() throws Exception {
        out.expectedMessageCount(1);

        ExchangeBuilder exchangeBuilder = new ExchangeBuilder(context).withHeader("set", ImmutableSet.of("a"));
        in.send(exchangeBuilder.build());

        out.assertIsSatisfied();
    }
}{code}

{code:java}
public class MethodNotFoundExceptionTest extends CamelTestSupport {

    public static class MethodNotFoundExceptionRoute extends RouteBuilder {

        @Override
        public void configure() throws Exception {
            from("seda:in").choice().when(simple("${headers.set.isEmpty()} != true")).to("mock:out");
        }
    }

    @Produce(uri = "seda:in")
    private ProducerTemplate in;

    @EndpointInject(uri = "mock:out")
    private MockEndpoint out;

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new MethodNotFoundExceptionRoute();
    }

    @Test
    public void methodNotFoundExceptionException() throws Exception {
        out.expectedMessageCount(1);

        ExchangeBuilder exchangeBuilder = new ExchangeBuilder(context).withHeader("set", ImmutableSet.of("a"));
        in.send(exchangeBuilder.build());

        out.assertIsSatisfied();
    }
}
{code}


> Simple Language: Set#size fails with AmbiguousMethodCallException
> -----------------------------------------------------------------
>
>                 Key: CAMEL-11235
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11235
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.19.0
>            Reporter: Pascal Schumacher
>            Priority: Minor
>             Fix For: 2.20.0
>
>
> After updating from 2.18.3 to 2.19.0 the following simple expression:
> {code}${headers.materialnumbers.size} != 0{code}
> (materialnumbers is a HashSet) fails with:
> {noformat}
> 2017-05-08 09:10:17,143 ERR [main] org.apache.camel.processor.DefaultErrorHandler - Failed
delivery for (MessageId: ID-RDDE102Y-57877-1494227416153-0-1 on ExchangeId: ID-RDDE102Y-57877-1494227416153-0-2).
Exhausted after delivery attempt: 1 caught: org.apache.camel.language.bean.RuntimeBeanExpressionException:
Failed to invoke method: size on null due to: org.apache.camel.component.bean.AmbiguousMethodCallException:
Ambiguous method invocations possible: [public abstract int java.util.Set.size(), public abstract
int java.util.AbstractCollection.size()]. Exchange[]
> Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId    ProcessorId          Processor                                           
                            Elapsed (ms)
> [Read TB ] [Read TB           ] [                                                   
                          ] [        67]
> [Read TB ] [choice1           ] [when[simple{Simple: ${headers.materialnumbers.size}
!= 0}]choice[]            ] [        62]
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------
> org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method:
size on null due to: org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
method invocations possible: [public abstract int java.util.Set.size(), public abstract int
java.util.AbstractCollection.size()]. Exchange[]
> 	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:327)
> 	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:115) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:139) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.builder.ExpressionBuilder$KeyedOgnlExpressionAdapter.evaluate(ExpressionBuilder.java:2490)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.builder.BinaryPredicateSupport.matchesReturningFailureMessage(BinaryPredicateSupport.java:60)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.builder.BinaryPredicateSupport.matches(BinaryPredicateSupport.java:50)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.language.simple.ast.BinaryExpression$5.evaluate(BinaryExpression.java:233)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:37)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:85) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.FilterProcessor.matches(FilterProcessor.java:65) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:93) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:529) [camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:497) [camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:365) [camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:497) [camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:209) [camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:139)
[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:374)
[camel-core-2.19.0.jar:2.19.0]
> Caused by: org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous method
invocations possible: [public abstract int java.util.Set.size(), public abstract int java.util.AbstractCollection.size()].
Exchange[]
> 	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:278) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:189) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:160) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:69) ~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:212)
~[camel-core-2.19.0.jar:2.19.0]
> 	at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:323)
~[camel-core-2.19.0.jar:2.19.0]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message