You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "allthingssecurity (via GitHub)" <gi...@apache.org> on 2026/10/10 00:05:01 UTC
[PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
allthingssecurity opened a new pull request, #27640:
URL: https://github.com/apache/camel/pull/27640
# Description
[CAMEL-25507](https://issues.apache.org/jira/browse/CAMEL-25507)
`LuceneComponent` parsed every endpoint URI into its single `LuceneConfiguration` and passed that same object to every endpoint, so each new lucene endpoint overwrote `host`, `operation`, `indexDir`, `analyzer` and `maxHits` of the others. The query producer reads them when it is created, at route start, after all routes were built. With several lucene endpoints in a CamelContext, a query therefore searches the index of the endpoint created last, with its analyzer and `maxHits`, and returns no hits or another index's documents without an error.
This change parses each URI into a copy of the component configuration (`LuceneConfiguration.copy()`, a shallow clone).
This is one of three independent camel-lucene fixes of the same batch (inserts after a restart, query producer state, per-endpoint configuration); they change different files and apply in any order.
Tests:
- New `LuceneEndpointConfigurationTest` in camel-lucene: two query endpoints on two indexes with different `maxHits`; checks each endpoint's options and that each query searches its own index.
- Without the change: `lucene:indexA:query?... must search its own index (10 alpha documents) with its own maxHits (5) ==> expected: <5> but was: <0>` (both tests fail).
- With the change, camel-lucene tests pass: `LuceneEndpointConfigurationTest` (2), `LuceneIndexAndQueryProducerIT` (4), `LuceneQueryProcessorIT` (2), 0 failures.
Found with a TLA+ model of endpoint creation and 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). I then reproduced it with the real component.
# Target
- [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
# Tracking
- [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
# Apache Camel coding standards and style
- [x] I checked that each commit in the pull request has a meaningful subject line and body.
- [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
(I built and tested camel-lucene, including the formatter and import-sort plugins; the build did not change any generated file. I did not run the full root build.)
# AI-assisted contributions
- [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used.
This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer.
_Claude Code on behalf of allthingssecurity_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27640:
URL: https://github.com/apache/camel/pull/27640#issuecomment-6094596853
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `components/camel-lucene`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 9 of 704 tested, 27 compile-only — current: 9 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **9 affected modules** (current approach: 9).
**Skip-tests mode would test 9 modules** (1 direct + 8 downstream), **skip tests for 27** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (9)</summary>
- `camel-jbang-mcp` ← downstream of org.apache.camel:camel-catalog
- `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
- `camel-jbang-plugin-route-parser` ← downstream of org.apache.camel:camel-route-parser
- `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-catalog
- `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-yaml-dsl-validator
- `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
- `camel-lucene` ← components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneComponent.java, components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneConfiguration.java, components/camel-lucene/src/test/java/org/apache/camel/component/lucene/LuceneEndpointConfigurationTest.java
- `camel-yaml-dsl-validator` ← downstream of org.apache.camel:camel-catalog
- `camel-yaml-dsl-validator-maven-plugin` ← downstream of org.apache.camel:camel-yaml-dsl-validator
</details>
<details><summary>Modules with tests skipped (27)</summary>
- `apache-camel`
- `camel-allcomponents`
- `camel-catalog`
- `camel-catalog-console`
- `camel-catalog-maven`
- `camel-catalog-suggest`
- `camel-componentdsl`
- `camel-endpointdsl`
- `camel-endpointdsl-support`
- `camel-itest`
- `camel-jbang-core`
- `camel-jbang-it`
- `camel-jbang-main`
- `camel-jbang-plugin-edit`
- `camel-jbang-plugin-generate`
- `camel-jbang-plugin-kubernetes`
- `camel-jbang-plugin-test`
- `camel-kamelet-main`
- `camel-launcher`
- `camel-report-maven-plugin`
- `camel-route-parser`
- `camel-yaml-dsl`
- `camel-yaml-dsl-deserializers`
- `camel-yaml-dsl-maven-plugin`
- `coverage`
- `docs`
- `dummy-component`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>All tested modules (36 modules, 6m 12s total)</summary>
**Total reactor time:** 6m 12s
| Module | Duration | Status |
| --- | --- | --- |
| Camel :: JBang :: Plugin :: TUI | 53.1s | SUCCESS |
| Camel :: Launcher | 52.9s | SUCCESS |
| Camel :: JBang :: MCP | 41.0s | SUCCESS |
| Camel :: Component DSL | 23.8s | SUCCESS |
| Camel :: Catalog :: Camel Catalog | 23.4s | SUCCESS |
| Camel :: YAML DSL | 18.6s | SUCCESS |
| Camel :: YAML DSL :: Validator | 17.8s | SUCCESS |
| Camel :: JBang :: Plugin :: Kubernetes | 17.4s | SUCCESS |
| Camel :: JBang :: Plugin :: Validate | 16.3s | SUCCESS |
| Camel :: Docs | 15.6s | SUCCESS |
| Camel :: JBang :: Plugin :: Testing | 13.2s | SUCCESS |
| Camel :: Kamelet Main | 11.7s | SUCCESS |
| Camel :: Lucene | 10.3s | SUCCESS |
| Camel :: YAML DSL :: Deserializers | 8.6s | SUCCESS |
| Camel :: Catalog :: Camel Route Parser | 8.0s | SUCCESS |
| Camel :: Catalog :: Camel Report Maven Plugin | 6.9s | SUCCESS |
| Camel :: YAML DSL :: Validator Maven Plugin | 5.0s | SUCCESS |
| Camel :: All Components Sync point | 5.0s | SUCCESS |
| Camel :: YAML DSL :: Maven Plugins | 3.5s | SUCCESS |
| Camel :: Catalog :: Maven | 2.9s | SUCCESS |
| Camel :: Catalog :: Suggest (deprecated) | 2.6s | SUCCESS |
| Camel :: JBang :: Plugin :: Edit | 1.7s | SUCCESS |
| Camel :: Coverage | 1.7s | SUCCESS |
| Camel :: Assembly | 1.6s | SUCCESS |
| Camel :: Catalog :: Dummy Component | 1.4s | SUCCESS |
| Camel :: JBang :: Plugin :: MCP | 1.4s | SUCCESS |
| Camel :: JBang :: Plugin :: Generate | 1.3s | SUCCESS |
| Camel :: JBang :: Integration tests | 1.2s | SUCCESS |
| Camel :: Catalog :: Console | 1.0s | SUCCESS |
| Camel :: Endpoint DSL :: Support | 0.8s | SUCCESS |
| Camel :: JBang :: Main | 0.7s | SUCCESS |
| Camel :: Launcher :: Container | 0.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Route Parser | 0.5s | SUCCESS |
| Camel :: Endpoint DSL | n/a | |
| Camel :: Integration Tests | n/a | |
| Camel :: JBang :: Core | n/a | |
**Top 20 slowest modules:**
- `Camel :: JBang :: Plugin :: TUI` (53.1s)
- `Camel :: Launcher` (52.9s)
- `Camel :: JBang :: MCP` (41.0s)
- `Camel :: Component DSL` (23.8s)
- `Camel :: Catalog :: Camel Catalog` (23.4s)
- `Camel :: YAML DSL` (18.6s)
- `Camel :: YAML DSL :: Validator` (17.8s)
- `Camel :: JBang :: Plugin :: Kubernetes` (17.4s)
- `Camel :: JBang :: Plugin :: Validate` (16.3s)
- `Camel :: Docs` (15.6s)
- `Camel :: JBang :: Plugin :: Testing` (13.2s)
- `Camel :: Kamelet Main` (11.7s)
- `Camel :: Lucene` (10.3s)
- `Camel :: YAML DSL :: Deserializers` (8.6s)
- `Camel :: Catalog :: Camel Route Parser` (8.0s)
- `Camel :: Catalog :: Camel Report Maven Plugin` (6.9s)
- `Camel :: YAML DSL :: Validator Maven Plugin` (5.0s)
- `Camel :: All Components Sync point` (5.0s)
- `Camel :: YAML DSL :: Maven Plugins` (3.5s)
- `Camel :: Catalog :: Maven` (2.9s)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/38007472530)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27640:
URL: https://github.com/apache/camel/pull/27640#discussion_r4236604318
##########
components/camel-lucene/src/test/java/org/apache/camel/component/lucene/LuceneEndpointConfigurationTest.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.lucene;
+
+import java.io.File;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.lucene.support.Hits;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.store.FSDirectory;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Each lucene endpoint keeps the options of its own URI, also when the CamelContext has several lucene endpoints.
+ */
+class LuceneEndpointConfigurationTest extends CamelTestSupport {
+
+ private static final String QUERY_A = "lucene:indexA:query?analyzer=#stdAnalyzer&indexDir=#dirA&maxHits=5";
+ private static final String QUERY_B = "lucene:indexB:query?analyzer=#stdAnalyzer&indexDir=#dirB&maxHits=20";
+
+ @TempDir
+ static File dirA;
+ @TempDir
+ static File dirB;
+
+ @BeforeAll
+ static void createIndexes() throws Exception {
+ createIndex(dirA, "alpha");
+ createIndex(dirB, "beta");
+ }
+
+ private static void createIndex(File indexDir, String term) throws Exception {
+ try (FSDirectory dir = FSDirectory.open(indexDir.toPath());
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(new StandardAnalyzer()))) {
+ for (int i = 0; i < 10; i++) {
+ Document doc = new Document();
+ doc.add(new TextField("contents", term + " document " + i, Field.Store.YES));
+ writer.addDocument(doc);
+ }
+ writer.commit();
+ }
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ registry.bind("dirA", dirA);
+ registry.bind("dirB", dirB);
+ registry.bind("stdAnalyzer", new StandardAnalyzer());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:a").to(QUERY_A);
+ from("direct:b").to(QUERY_B);
+ }
+ };
+ }
+
+ @Test
+ void endpointsKeepTheirOwnOptions() {
+ LuceneEndpoint a = context.getEndpoint(QUERY_A, LuceneEndpoint.class);
+ LuceneEndpoint b = context.getEndpoint(QUERY_B, LuceneEndpoint.class);
+ assertEquals(dirA, a.getConfig().getIndexDir(), "indexDir of " + QUERY_A);
+ assertEquals(5, a.getConfig().getMaxHits(), "maxHits of " + QUERY_A);
+ assertEquals("indexA", a.getConfig().getHost(), "host of " + QUERY_A);
+ assertEquals(dirB, b.getConfig().getIndexDir(), "indexDir of " + QUERY_B);
Review Comment:
Nit: you could also assert endpoint B's own `maxHits` and `host`, so the test covers both directions of the overwrite:
```suggestion
assertEquals(dirB, b.getConfig().getIndexDir(), "indexDir of " + QUERY_B);
assertEquals(20, b.getConfig().getMaxHits(), "maxHits of " + QUERY_B);
assertEquals("indexB", b.getConfig().getHost(), "host of " + QUERY_B);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
Posted by "allthingssecurity (via GitHub)" <gi...@apache.org>.
allthingssecurity commented on code in PR #27640:
URL: https://github.com/apache/camel/pull/27640#discussion_r4236657127
##########
components/camel-lucene/src/test/java/org/apache/camel/component/lucene/LuceneEndpointConfigurationTest.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.lucene;
+
+import java.io.File;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.lucene.support.Hits;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.store.FSDirectory;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Each lucene endpoint keeps the options of its own URI, also when the CamelContext has several lucene endpoints.
+ */
+class LuceneEndpointConfigurationTest extends CamelTestSupport {
+
+ private static final String QUERY_A = "lucene:indexA:query?analyzer=#stdAnalyzer&indexDir=#dirA&maxHits=5";
+ private static final String QUERY_B = "lucene:indexB:query?analyzer=#stdAnalyzer&indexDir=#dirB&maxHits=20";
+
+ @TempDir
+ static File dirA;
+ @TempDir
+ static File dirB;
+
+ @BeforeAll
+ static void createIndexes() throws Exception {
+ createIndex(dirA, "alpha");
+ createIndex(dirB, "beta");
+ }
+
+ private static void createIndex(File indexDir, String term) throws Exception {
+ try (FSDirectory dir = FSDirectory.open(indexDir.toPath());
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(new StandardAnalyzer()))) {
+ for (int i = 0; i < 10; i++) {
+ Document doc = new Document();
+ doc.add(new TextField("contents", term + " document " + i, Field.Store.YES));
+ writer.addDocument(doc);
+ }
+ writer.commit();
+ }
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ registry.bind("dirA", dirA);
+ registry.bind("dirB", dirB);
+ registry.bind("stdAnalyzer", new StandardAnalyzer());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:a").to(QUERY_A);
+ from("direct:b").to(QUERY_B);
+ }
+ };
+ }
+
+ @Test
+ void endpointsKeepTheirOwnOptions() {
+ LuceneEndpoint a = context.getEndpoint(QUERY_A, LuceneEndpoint.class);
+ LuceneEndpoint b = context.getEndpoint(QUERY_B, LuceneEndpoint.class);
+ assertEquals(dirA, a.getConfig().getIndexDir(), "indexDir of " + QUERY_A);
+ assertEquals(5, a.getConfig().getMaxHits(), "maxHits of " + QUERY_A);
+ assertEquals("indexA", a.getConfig().getHost(), "host of " + QUERY_A);
+ assertEquals(dirB, b.getConfig().getIndexDir(), "indexDir of " + QUERY_B);
Review Comment:
Added the `maxHits` and `host` assertions for endpoint B in eff2860e9b, so the test covers both directions of the overwrite; camel-lucene tests pass.
_Claude Code on behalf of allthingssecurity_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #27640:
URL: https://github.com/apache/camel/pull/27640
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-25507: camel-lucene - Each endpoint keeps the options of its own URI [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27640:
URL: https://github.com/apache/camel/pull/27640#issuecomment-6094368399
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org