【问题标题】:Default method is invisible during Camel Simple evaluation在骆驼简单评估期间默认方法不可见
【发布时间】:2017-09-17 01:43:13
【问题描述】:

问题可以通过以下单元测试重现,我在跟踪器中没有找到它。 本质:接口 A 有默认方法,接口 B 扩展 A,在简单语言评估期间默认方法是不可见的。 骆驼版本 2.16.1。我错过了什么吗?

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;
import org.junit.Assert;
import org.junit.Test;

public class DefaultMethodIsInvisibleTest {
    @Test
    public void camelSimpleDoesNotSeeDefaultMethod() throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("direct:camelSimpleDoesNotSeeDefaultMethod").log("Result of default method invocation is ${exchangeProperty.myObject.defaultMethod}");
            }
        });
        context.start();

        Exchange incomingExchange = new DefaultExchange(context);
        incomingExchange.setProperty("myObject", new B() {
        });

        Exchange result = context.createProducerTemplate().send("direct:camelSimpleDoesNotSeeDefaultMethod", incomingExchange);

        Assert.assertNull(result.getException());
    }

public static interface A {
    public default String defaultMethod() {
        return "default method result";
    }
}

public static interface B extends A {
}
}

堆栈跟踪:

Caused by: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: defaultMethod on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: defaultMethod not found on bean: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2@5dafbe45 of type: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2. Exchange[][Message: [Body is null]]
    at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:290)
    at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)
    ... 46 common frames omitted
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: defaultMethod not found on bean: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2@5dafbe45 of type: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2. Exchange[][Message: [Body is null]]
    at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:269)
    at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
    at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:159)

【问题讨论】:

    标签: java-8 apache-camel default-method


    【解决方案1】:

    接口上的默认方法不明确支持 AFAIR。欢迎您登录 JIRA

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 1970-01-01
      相关资源
      最近更新 更多