You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/10/10 07:38:00 UTC
[jira] [Resolved] (CAMEL-25507) camel-lucene - with several lucene endpoints, a query searches the index of the endpoint created last
[ https://issues.apache.org/jira/browse/CAMEL-25507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-25507.
---------------------------------
Resolution: Fixed
Fixed by https://github.com/apache/camel/pull/27640 (merged as 0216fa9989604d9b688afab3d30a4ace8fa8fc4e).
_Claude Code on behalf of Claus Ibsen_
> 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
> Fix For: 4.23.0
>
>
> {{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)