[
https://issues.apache.org/jira/browse/CAMEL-25507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-25507 started by shashank.
----------------------------------------
> camel-lucene - with several lucene endpoints, a query searches the index of
> the endpoint created last
> -----------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25507
> URL: https://issues.apache.org/jira/browse/CAMEL-25507
> Project: Camel
> Issue Type: Bug
> Components: camel-lucene
> Reporter: shashank
> Assignee: shashank
> Priority: Major
>
> {{LuceneComponent}} holds one {{LuceneConfiguration}} ({{config}}, lines
> 34-41 at main c578a42a776d) and {{createEndpoint}} does {{config.parseURI(new
> URI(uri), parameters, this)}} and {{new LuceneEndpoint(uri, this, config)}}
> (lines 45-48). Every endpoint gets the same configuration object, and every
> new endpoint overwrites its {{host}}, {{operation}}, {{indexDir}},
> {{analyzer}} and {{maxHits}} ({{parseURI}} sets all of them, with defaults
> for the missing options).
> An insert endpoint reads the configuration in its constructor, so it is not
> affected. A query endpoint reads it when its producer is created
> ({{LuceneQueryProducer}} constructor), which happens when the route starts
> ({{SendProcessor.doStart}}), after all routes were built. So in a
> CamelContext with more than one lucene endpoint, every query producer
> searches the {{indexDir}} of the endpoint created last, with that endpoint's
> analyzer and {{maxHits}}: it returns no hits, the documents of another index,
> or a different number of hits, without any error. {{getConfig()}} of every
> endpoint also reports the last endpoint's options.
> h3. Reproduction
> New {{LuceneEndpointConfigurationTest}}: two indexes ({{dirA}} with 10
> "alpha" documents, {{dirB}} with 10 "beta" documents) and two routes
> {{direct:a}} to {{lucene:indexA:query?...&indexDir=#dirA&maxHits=5}} and
> {{direct:b}} to {{lucene:indexB:query?...&indexDir=#dirB&maxHits=20}}. On
> main:
> {noformat}
> endpointsKeepTheirOwnOptions: indexDir of lucene:indexA:query?... ==>
> expected: <.../junit-1473...> but was: <.../junit-6515...>
> eachQueryEndpointSearchesItsOwnIndex: lucene:indexA:query?... must search its
> own index (10 alpha documents) with its own maxHits (5) ==> expected: <5> but
> was: <0>
> {noformat}
> h3. Proposed fix
> {{createEndpoint}} parses the URI into a copy of the component configuration
> ({{LuceneConfiguration.copy()}}, a shallow clone, the pattern other
> components use). The component-level configuration stays the starting point
> of each endpoint, as before; no option changes. camel-lucene tests with the
> fix: {{LuceneEndpointConfigurationTest}} 2, {{LuceneIndexAndQueryProducerIT}}
> 4, {{LuceneQueryProcessorIT}} 2, 0 failures.
> Found with a TLA+ model of endpoint creation (parse into the configuration
> object), the insert indexer and the query producer creation: "a query
> producer uses the options of its own endpoint" is violated in 3 steps (create
> endpoint A, create endpoint B, start A's producer), and for an insert
> endpoint followed by a query endpoint; "an insert endpoint indexes into its
> own directory" holds on main (it reads the options at creation). With the fix
> both hold in any order of endpoint and producer creation. Then confirmed with
> the real component as above.
> Affected: main, camel-4.22.x, camel-4.18.x, camel-4.14.x (same code, GitHub
> contents API).
> Duplicate check (2026-10-09): JIRA component camel-lucene with "indexDir" or
> "configuration" (none), component camel-lucene (8 issues, all upgrades or
> naming); GitHub pull requests "camel-lucene": none about the configuration.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)