camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernard Ligny (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-10236) BeanProccessor - method invocation with generics+annotations
Date Fri, 12 Aug 2016 07:43:20 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-10236?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Bernard Ligny updated CAMEL-10236:
----------------------------------
    Description: 
The following code does not work:

{code:java}
public interface Transformer<T> {	
	 public Object convert(T input) throws Exception;
}

public class MyTransformer implements Transformer<InputStream> {
    @Override
    public Object convert(@Body InputStream body) {...}
}

from("direct:foo")
.transform().method(new MyTransformer(), "convert")
.log("${body}");
{code}

Stack trace:
{noformat}
java.lang.ClassCastException: [B cannot be cast to java.io.InputStream
	at net.haulogy.erpgis.esb.transformers.MyTransformer.convert(MyTransformer.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
	at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
	at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:126)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
	at org.apache.camel.processor.TransformProcessor.process(TransformProcessor.java:50)
{noformat}

But this is working fine:
{code:java}
public class MyTransformer {
    public Object convert(@Body InputStream body) {...}
}

from("direct:foo")
.transform().method(new MyTransformer(), "convert")
.log("${body}");
{code}

  was:
The following code does not work:

{code:java}
public interface Transformer<T> {	
	 public Object convert(T input) throws Exception;
}

public class MyTransformer implements Transformer<InputStream> {
    @Override
    public Object convert(@Body InputStream body) {...}
}


from("direct:foo")
.transform().method(new MyTransformer(), "convert")
.log("${body}");
{code}

Stack trace:
{noformat}
java.lang.ClassCastException: [B cannot be cast to java.io.InputStream
	at net.haulogy.erpgis.esb.transformers.MyTransformer.convert(MyTransformer.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
	at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
	at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:126)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
	at org.apache.camel.processor.TransformProcessor.process(TransformProcessor.java:50)
{noformat}


> BeanProccessor - method invocation with generics+annotations
> ------------------------------------------------------------
>
>                 Key: CAMEL-10236
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10236
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.17.2
>            Reporter: Bernard Ligny
>            Priority: Minor
>
> The following code does not work:
> {code:java}
> public interface Transformer<T> {	
> 	 public Object convert(T input) throws Exception;
> }
> public class MyTransformer implements Transformer<InputStream> {
>     @Override
>     public Object convert(@Body InputStream body) {...}
> }
> from("direct:foo")
> .transform().method(new MyTransformer(), "convert")
> .log("${body}");
> {code}
> Stack trace:
> {noformat}
> java.lang.ClassCastException: [B cannot be cast to java.io.InputStream
> 	at net.haulogy.erpgis.esb.transformers.MyTransformer.convert(MyTransformer.java:1)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
> 	at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
> 	at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
> 	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
> 	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
> 	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211)
> 	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:126)
> 	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
> 	at org.apache.camel.processor.TransformProcessor.process(TransformProcessor.java:50)
> {noformat}
> But this is working fine:
> {code:java}
> public class MyTransformer {
>     public Object convert(@Body InputStream body) {...}
> }
> from("direct:foo")
> .transform().method(new MyTransformer(), "convert")
> .log("${body}");
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message