Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0
-
None
Description
It's not possible to set the delimiter parameter in spring configuration file or I don't find the way to do it !
For example :
<route id="routeA">
<from uri="file:src/test/resources/csv?move=done/&fileName=testfileRouteA.csv" />
<to uri="flatpack:delim:META-INF/Delimited.pzmap.xml?delimiter=;" />
</route>
I get the following error :
Exception in thread "main" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route routeA at: >>> To[flatpack:delim:META-INF/Delimited.pzmap.xml?ignoreFirstRecord=false&splitRows=true&delimiter=;] <<< in route: Route[[From[file:src/test/resources/csv?move=done/&fileName=... because of Failed to resolve endpoint: flatpack://delim:META-INF/Delimited.pzmap.xml?delimiter=%3B&ignoreFirstRecord=false&splitRows=true due to: Could not find a suitable setter for property: delimiter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: char with value ;
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:219)
at org.apache.camel.spring.Main.doStart(Main.java:173)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
at org.apache.camel.impl.MainSupport.run(MainSupport.java:114)
at org.apache.camel.impl.MainSupport.run(MainSupport.java:291)
at org.apache.camel.spring.Main.main(Main.java:97)
If it's a bug, to solve it, it's just necessary to change the class org.apache.camel.component.flatpack.DelimitedEndpoint as below :
- change the flied definition like this (and getter/setter to):
private String delimiter = ",";
private String textQualifier = "\"";
- and the the method createParser like this :
public Parser createParser(Exchange exchange) throws InvalidPayloadException, IOExceptionUnknown macro: { Reader bodyReader = ExchangeHelper.getMandatoryInBody(exchange, Reader.class); Resource resource = getResource(); if (delimiter == null || delimiter.equals("")) delimiter = ","; if (textQualifier == null || textQualifier.equals("")) textQualifier = """; if (resource == null) { return getParserFactory().newDelimitedParser(bodyReader, delimiter.charAt(0), textQualifier.charAt(0)); } else { return getParserFactory().newDelimitedParser(new InputStreamReader(resource.getInputStream()), bodyReader, delimiter.charAt(0), textQualifier.charAt(0), ignoreFirstRecord); } }