为组件绑定生成的代理通过NullPayload引发ClassCastException

时间:2012-05-18 21:29:35

标签: mule

当服务调用返回null(NullPayload)时,为组件绑定生成的代理会抛出ClassCastException。它应该返回null吗? (这是在Mule CE 3.2.1中)参见MULE 4405

由于

这是mule配置:

<mule ...>

    <flow name="entryPoint">
        <vm:inbound-endpoint
            path="entryPoint"
            exchange-pattern="request-response" />
        <component class="classcastexception.Component">
            <binding interface="classcastexception.Interface" method="foo">
                <vm:outbound-endpoint
                    path="classcastexception.Interface.foo"
                    exchange-pattern="request-response" />
            </binding>
        </component>
    </flow>

    <flow name="classcastexception.Interface.foo">
        <vm:inbound-endpoint
            path="classcastexception.Interface.foo"
            exchange-pattern="request-response" />
        <component class="classcastexception.InterfaceImpl" />
    </flow>

</mule>

java类是:

Interface.java

package classcastexception;

public interface Interface {

    String foo(String s);

}

Component.java

package classcastexception;

public class Component {

    private Interface i;

    public String foo(final String s) {
        return i.foo(s);
    }

    public void setInterface(final Interface i) {
        this.i = i;
    }

}

InterfaceImpl.java

package classcastexception;

public class InterfaceImpl implements Interface {

    @Override
    public String foo(String s) {
        return null;
    }

}

1 个答案:

答案 0 :(得分:1)

最近修复了此错误。有关更多信息,请查看MULE-6287 jira。正如您所看到的,此修复程序将包含在即将发布的mule 3.3中。