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

Claus Ibsen updated CAMEL-16494:
--------------------------------
    Priority: Minor  (was: Major)

> After VetoCamelContextStartException CamelContext instance broken forever
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-16494
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16494
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 3.7.3
>            Reporter: Valeriy Ak
>            Priority: Minor
>
> After camel context failed to start with VetoCamelContextStartException, it 
> never can be started again.
> It happens because AbstractCamelContext.init() method checks *vetoed* is not 
> null.  This method throw RuntimeException  (even if rethrowException = false, 
> because called fail(vetoed)).
> *Vetoed* field is cleaned in method doStartContext only.
>  AbstractCamelContext code:
> {code:java}
> init(); //<--- this method throws RuntimeException when vetoed != null
> try (AutoCloseable ignored = doLifecycleChange()) {
>     status = STARTING;
>     LOG.trace("Starting service: {}", this);
>     doStart();  //<-- this method sets vetoed == null{code}
>  
> Example for reproduce:
> {code:java}
> import org.apache.camel.CamelContext;
> import org.apache.camel.VetoCamelContextStartException;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.camel.support.LifecycleStrategySupport;
> public class CamelContextVetoExceptionBug {
>     public static void main(String[] args) {
>         CamelContext context = new DefaultCamelContext();
>         boolean[] needThrow = new boolean[]{true};
>         context.addLifecycleStrategy(new LifecycleStrategySupport() {
>             @Override
>             public void onContextStarting(CamelContext context) throws 
> VetoCamelContextStartException {
>                 if (needThrow[0]) {
>                     needThrow[0] = false;
>                     throw new VetoCamelContextStartException("Veto 
> onContextStarting", context, false);
>                 }
>             }
>         });
>         context.start();
>         System.out.println("Start failed without rethrow: veto=" + 
> context.isVetoStarted());
>         try {
>             context.start();
>         } catch (Exception e) {
>             System.out.println("Exception: veto=" + context.isVetoStarted());
>         }
>     }
> } {code}
>  
> Expected behavior:
>  * next context start does not thow RuntimeException
>  * next context start - started context
>  
>   



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to