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

Claus Ibsen updated CAMEL-26651:
--------------------------------
    Fix Version/s: 4.24.0

> camel-git - the consumer ignores the scheduler and error handler options: 
> delay is always 500 ms
> ------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26651
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26651
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-git
>    Affects Versions: 4.10.0, 4.14.9, 4.18.5, 4.22.2, 4.23.0
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Major
>             Fix For: 4.24.0
>
>
> h3. Problem
> Since CAMEL-19665 (first released in 4.10.0), {{GitEndpoint}} extends 
> {{ScheduledPollEndpoint}}, so the catalog and the documentation list the 
> scheduler options for the git consumer. But {{GitEndpoint.createConsumer}} 
> never calls {{configureConsumer(consumer)}}: it returns {{new 
> GitCommitConsumer/GitTagConsumer/GitBranchConsumer(this, processor)}} 
> directly 
> ({{components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java}}
>  lines 158-168, main commit 7978db3d42dd).
> As a result, nothing copies the endpoint options to the consumer:
> * {{ScheduledPollEndpoint.doConfigureConsumer}} options: delay, initialDelay, 
> startScheduler, greedy, backoffErrorThreshold, backoffIdleThreshold, 
> backoffMultiplier, repeatCount, pollStrategy, runLoggingLevel, 
> scheduledExecutorService, sendEmptyMessageWhenIdle, timeUnit, useFixedDelay, 
> scheduler and schedulerProperties.
> * {{DefaultEndpoint.configureConsumer}} options: bridgeErrorHandler and 
> exceptionHandler.
> The URI accepts these options and they are ignored without any warning. The 
> consumer always polls with the {{ScheduledPollConsumer}} defaults: 
> initialDelay 1000 ms and delay 500 ms.
> The source is the same in camel-4.10.0, 4.14.9, 4.18.5, 4.22.2, 4.23.0 and 
> main: none of them calls {{configureConsumer}}. In 4.8.0 the endpoint was a 
> {{DefaultEndpoint}}, so bridgeErrorHandler and exceptionHandler were already 
> ignored there, but the scheduler options did not exist yet.
> h3. How to reproduce
> Measured on main with a JUnit test, against a JGit repository in a temporary 
> directory:
> {code:java}
> GitEndpoint ep = context.getEndpoint("git:" + dir
>         + 
> "?type=commit&branchName=master&delay=60000&initialDelay=5000&startScheduler=false",
>  GitEndpoint.class);
> assertEquals(60000, ep.getDelay());
> GitCommitConsumer consumer = (GitCommitConsumer) ep.createConsumer(e -> { });
> assertEquals(500, consumer.getDelay());          // not 60000
> assertEquals(1000, consumer.getInitialDelay());  // not 5000
> assertTrue(consumer.isStartScheduler());         // not false
> {code}
> Output: {{endpoint delay=60000 initialDelay=5000 startScheduler=false, 
> consumer delay=500 initialDelay=1000 startScheduler=true}}.
> In an earlier run of the same test, {{startScheduler=false}} was set only on 
> the URI. The scheduler still polled in the background, at the same time as 
> the test's own {{poll()}} calls: more commits were delivered than the 
> repository had.
> For comparison, from the source: {{GitHub2Endpoint.createConsumer}} in 
> camel-github2 does call {{configureConsumer}}.
> h3. Proposed change
> * Call {{configureConsumer(consumer)}} in {{GitEndpoint.createConsumer}} 
> before returning, as the other {{ScheduledPollEndpoint}} components do.
> * Add a test that sets delay, initialDelay, startScheduler and 
> bridgeErrorHandler, and checks them on the consumer.
> * Raising the default delay of the git consumer would be a separate decision: 
> every idle poll walks the whole history of the branch. It was measured at 720 
> ms per idle poll for 32k commits, growing about 3.4 times for each doubling 
> of the commit count.
> h3. Impact / upgrade
> * No default value changes. Routes that set these options get what they 
> configured: for example, {{delay=60000}} now really polls once a minute, and 
> {{bridgeErrorHandler=true}} now applies.
> * That behaviour change is visible to existing routes, so a short note in the 
> 4.24 upgrade guide is worthwhile.
> * It affects all three consumer types (commit, tag and branch). The producer 
> is not affected.
> h3. Related
> * See also CAMEL-26652: failed exchanges are marked consumed and never 
> delivered again. Its fix relies on the exception handler and on a delay that 
> can be raised.
> * CAMEL-19665 (commits 51f270663f86 and 83ab5f1536c5) changed {{GitEndpoint}} 
> from {{DefaultEndpoint}} to {{ScheduledPollEndpoint}} without adding the call.
> * Similar bugs, already fixed: CAMEL-22558 (the camel-jira consumer ignored 
> the delay option) and CAMEL-24357 (the camel-aws2-s3-vectors consumer ignored 
> the delay option).
> _Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to