SpringFramework caches a missed TypeConverter used by Camel and user can not clean it
Issue
Once getProperties(String, Class) fails, it will never work for the same arguments.
camel route
@Override
public void configure() throws Exception {
from("timer://foo?repeatCount=1")
.bean(myBean, "setArrayList") // Set a correct Object
.bean(myBean, "checkSampleProperty") // It sould work
.bean(myBean, "setEmptyArrayList") // Set incorrect Object
.bean(myBean, "checkSampleProperty") // It should fail
.bean(myBean, "setArrayList") // Set a correct Object again
.bean(myBean, "checkSampleProperty"); // It should work. But actually, it will return null.
}
myBean
public class SampleBean {
private final static Logger LOG = LoggerFactory.getLogger(SampleBean.class);
public void setEmptyArrayList(Exchange exchange) {
ArrayList<Dummy> list = new ArrayList<Dummy>();
exchange.setProperty("sample", list);
}
public void setArrayList(Exchange exchange) {
ArrayList<Dummy> list = new ArrayList<Dummy>();
list.add(new Dummy());
exchange.setProperty("sample", list);
}
public void checkSampleProperty( Exchange exchange) {
ArrayList list = (ArrayList) exchange.getProperty("sample");
LOG.info("ArrayList size: " + list.size());
Dummy dummy = exchange.getProperty("sample", Dummy.class);
LOG.info("dummy object:" + dummy);
}
}
log
15:05:39.071 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - ArrayList size: 1
15:05:39.072 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - dummy object:org.mycompany.Dummy@59fc9224
15:05:39.073 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - ArrayList size: 0
15:05:39.073 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - dummy object:null
15:05:39.074 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - ArrayList size: 1
15:05:39.074 [Camel (MyCamel) thread #1 - timer://foo] INFO org.mycompany.SampleBean - dummy object:null
Environment
- Red Hat Fuse
- 7.11.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.