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

Claus Ibsen updated CAMEL-24510:
--------------------------------
    Component/s: came-core

> ExchangeHelper.convertToType throws NPE when CamelContext.getTypeConverter() 
> is null during shutdown
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24510
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24510
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>            Reporter: mayur mohan
>            Priority: Minor
>              Labels: camel-support, diagnostic
>
> h2. Problem
> When a typed {{exchange.getProperty(name, Class)}} is called and the stored 
> value requires type conversion, {{ExchangeHelper.convertToType()}} calls 
> {{exchange.getContext().getTypeConverter().convertTo(...)}}. If 
> {{getTypeConverter()}} returns {{null}} (e.g. during CamelContext shutdown, 
> OSGi bundle refresh, or context not fully initialized), a bare 
> {{NullPointerException}} is thrown with no actionable message.
> h2. Stack Trace
> {noformat}
> java.lang.NullPointerException: Cannot invoke 
> "org.apache.camel.TypeConverter.convertTo(java.lang.Class, 
> org.apache.camel.Exchange, Object)"
>     because the return value of 
> "org.apache.camel.CamelContext.getTypeConverter()" is null
>     at 
> org.apache.camel.support.ExchangeHelper.convertToType(ExchangeHelper.java:261)
>     at 
> org.apache.camel.support.AbstractExchange.getProperty(AbstractExchange.java:321)
>     at 
> org.apache.camel.support.DefaultExchange.getProperty(DefaultExchange.java:27)
>     at 
> com.sap.esb.camel.ftp.sap.sftp.component.SapSftpConsumer.isStopOnExceptionEnabled(SapSftpConsumer.java:189)
>     at 
> org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:202)
>     at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
> {noformat}
> h2. Fix
> Add null guards in both methods, throwing a descriptive 
> {{IllegalStateException}} instead of bare NPE.
> h2. PR
> https://github.com/apache/camel/pull/25760



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to