You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/09/21 08:08:40 UTC

[PR] CAMEL-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

davsclaus opened a new pull request, #26665:
URL: https://github.com/apache/camel/pull/26665

   Fixes https://issues.apache.org/jira/browse/CAMEL-24865
   
   Under `camel run --source-dir` the resource loader replaced every `classpath:` or `file:` resource that was not found with `file:<source-dir>/<path>`, whether or not that file existed. A resource that was optional (`?optional=true`) then stopped being optional: `JavaLanguage` could not initialise (`classpath:camel-joor.properties?optional=true` became a file that did not exist), so the `spring.datasource.url` auto-configure recipe never ran and any sql route failed with `Property 'dataSource' is required`.
   
   The same app started with `camel run sql.camel.yaml application.properties` worked. With this change the source-dir branch only replaces the answer when the file exists, like the fallback-dirs branch already did; a resource that exists nowhere keeps its original answer so errors name the location as written.
   
   Test: `DependencyDownloaderResourceLoaderTest.aMissingResourceUnderSourceDirIsStillMissing`. Verified by hand with an H2 datasource app under `--source-dir`: the datasource is configured and the table is created.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj


-- 
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-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #26665:
URL: https://github.com/apache/camel/pull/26665


-- 
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-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #26665:
URL: https://github.com/apache/camel/pull/26665#discussion_r4060689984


##########
dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/DependencyDownloaderResourceLoaderTest.java:
##########
@@ -61,6 +61,20 @@ void aResourceThatIsNowhereKeepsItsName() {
         assertEquals("classpath:missing.groovy", resource.getLocation(), "the error names the resource as written");
     }
 
+    /** CAMEL-24865: under --source-dir a resource that exists nowhere keeps its original (not found) answer. */
+    @Test
+    void aMissingResourceUnderSourceDirIsStillMissing() throws Exception {
+        Path sourceDir = Files.createDirectory(routes.resolve("src"));
+        SimpleCamelContext context = new SimpleCamelContext();
+        DependencyDownloaderResourceLoader loader
+                = new DependencyDownloaderResourceLoader(context, sourceDir.toString(), List.of());
+
+        Resource resource = loader.resolveResource("classpath:camel-joor.properties");

Review Comment:
   Added as suggested: the test now also resolves `classpath:camel-joor.properties?optional=true` and checks it stays the original, non-existing classpath resource.



-- 
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-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26665:
URL: https://github.com/apache/camel/pull/26665#issuecomment-5757371319

   :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


Re: [PR] CAMEL-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #26665:
URL: https://github.com/apache/camel/pull/26665#discussion_r4060362317


##########
dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/DependencyDownloaderResourceLoaderTest.java:
##########
@@ -61,6 +61,20 @@ void aResourceThatIsNowhereKeepsItsName() {
         assertEquals("classpath:missing.groovy", resource.getLocation(), "the error names the resource as written");
     }
 
+    /** CAMEL-24865: under --source-dir a resource that exists nowhere keeps its original (not found) answer. */
+    @Test
+    void aMissingResourceUnderSourceDirIsStillMissing() throws Exception {
+        Path sourceDir = Files.createDirectory(routes.resolve("src"));
+        SimpleCamelContext context = new SimpleCamelContext();
+        DependencyDownloaderResourceLoader loader
+                = new DependencyDownloaderResourceLoader(context, sourceDir.toString(), List.of());
+
+        Resource resource = loader.resolveResource("classpath:camel-joor.properties");

Review Comment:
   💡 The test uses `"classpath:camel-joor.properties"` (no query param), but the JIRA ticket describes the failure as `classpath:camel-joor.properties?optional=true`. Both work with the fix, but adding a second assertion with the `?optional=true` form would directly prove the regression is gone:
   
   ```java
           // The bug URI: with ?optional=true it must still be optional after the fix
           Resource optional = loader.resolveResource("classpath:camel-joor.properties?optional=true");
           assertFalse(optional.exists());
           assertEquals("classpath:camel-joor.properties?optional=true", optional.getLocation(),
                   "?optional=true resource must not be replaced by a non-existent file");
   ```



-- 
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-24865: camel-jbang - source-dir must not replace a missing classpath resource with a missing file [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #26665:
URL: https://github.com/apache/camel/pull/26665#issuecomment-5757704473

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `dsl/camel-kamelet-main`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 6 of 692 tested, 9 compile-only — current: 6 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **16 affected modules** (current approach: 6).
   
   **Skip-tests mode would test 6 modules** (1 direct + 6 downstream), **skip tests for 9** (generated code, meta-modules)
   
   <details><summary>:warning: Modules only in Scalpel (10)</summary>
   
   - `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`
   - `coverage`
   
   </details>
   
   
   <details><summary>Modules Scalpel would test (6)</summary>
   
   - `camel-jbang-mcp` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-route-parser` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-kamelet-main` ← dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderResourceLoader.java, dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/DependencyDownloaderResourceLoaderTest.java
   - `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
   
   </details>
   
   <details><summary>Modules with tests skipped (9)</summary>
   
   - `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-launcher`
   - `coverage`
   
   </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 (16 modules, 3m 27s total)</summary>
   
   **Total reactor time:** 3m 27s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: Launcher | 51.0s | SUCCESS |
   | Camel :: JBang :: Plugin :: TUI | 50.6s | SUCCESS |
   | Camel :: JBang :: MCP | 39.5s | SUCCESS |
   | Camel :: JBang :: Plugin :: Kubernetes | 22.3s | SUCCESS |
   | Camel :: Kamelet Main | 12.0s | SUCCESS |
   | Camel :: JBang :: Plugin :: Testing | 10.3s | SUCCESS |
   | Camel :: JBang :: Plugin :: Validate | 7.8s | SUCCESS |
   | Camel :: Coverage | 5.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Edit | 1.7s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 1.6s | SUCCESS |
   | Camel :: JBang :: Plugin :: Generate | 1.4s | SUCCESS |
   | Camel :: JBang :: Integration tests | 1.2s | SUCCESS |
   | Camel :: JBang :: Plugin :: Route Parser | 1.1s | SUCCESS |
   | Camel :: JBang :: Main | 1.0s | SUCCESS |
   | Camel :: Launcher :: Container | 0.8s | SUCCESS |
   | Camel :: JBang :: Core | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: Launcher` (51.0s)
   - `Camel :: JBang :: Plugin :: TUI` (50.6s)
   - `Camel :: JBang :: MCP` (39.5s)
   - `Camel :: JBang :: Plugin :: Kubernetes` (22.3s)
   - `Camel :: Kamelet Main` (12.0s)
   - `Camel :: JBang :: Plugin :: Testing` (10.3s)
   - `Camel :: JBang :: Plugin :: Validate` (7.8s)
   - `Camel :: Coverage` (5.2s)
   - `Camel :: JBang :: Plugin :: Edit` (1.7s)
   - `Camel :: JBang :: Plugin :: MCP` (1.6s)
   - `Camel :: JBang :: Plugin :: Generate` (1.4s)
   - `Camel :: JBang :: Integration tests` (1.2s)
   - `Camel :: JBang :: Plugin :: Route Parser` (1.1s)
   - `Camel :: JBang :: Main` (1.0s)
   - `Camel :: Launcher :: Container` (0.8s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/35576337017)


-- 
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