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

Re: [PR] CAMEL-23858: camel-spring-boot - Configuring camel.main.profile shoul… [camel-spring-boot]

vilmosnagy commented on code in PR #1832:
URL: https://github.com/apache/camel-spring-boot/pull/1832#discussion_r3613196202


##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java:
##########
@@ -230,6 +236,27 @@ public static CamelContext doConfigureCamelContext(ApplicationContext applicatio
         return camelContext;
     }
 
+    /**
+     * Collect all camel.main.* property names that the user has explicitly configured
+     * so that ProfileConfigurer does not override them with profile defaults.
+     */
+    protected static Properties doExtractCamelMainProperties(ApplicationContext applicationContext) {
+        Properties answer = new Properties();
+        Environment env = applicationContext.getEnvironment();
+        if (env instanceof ConfigurableEnvironment cev) {
+            cev.getPropertySources().forEach(ps -> {
+                if (ps instanceof EnumerablePropertySource<?> eps) {
+                    for (String n : eps.getPropertyNames()) {
+                        if (n.startsWith("camel.main.")) {
+                            answer.put(n, cev.getProperty(n, ""));
+                        }
+                    }

Review Comment:
   @davsclaus this seems to throw an exception sometimes when n is null. Seems to fail when adding an yaml file with the following content to the following arg `--spring.config.additional-location`:
   
   ```yaml
   {}
   ```
   
   Test method which fails:
   
   ```
       @Test
       void configFileWithNoDeprecatedPropertyShouldStartSuccessfully(@TempDir Path tempDir, CapturedOutput output) throws IOException {
           Path configFile = writeEmptyConfig(tempDir);
           List<String> args = baseArgs();
           args.add("--spring.config.additional-location=classpath:/itests/mav/application.yaml,file:" + configFile.toAbsolutePath());
   
           final var app = assertDoesNotThrow(() ->
                   SpringApplication
                           .from(DataWizardApplication::main)
                           .run(args.toArray(String[]::new))
           );
           app.getApplicationContext().close();
           assertThat(output.getAll()).doesNotContain("[Deprecated since");
       }
   
       private static Path writeEmptyConfig(Path tempDir) throws IOException {
           Path file = tempDir.resolve("deprecation-test.yaml");
           Files.writeString(file, "{}");
           return file;
       }
   ```
   
   I'll try to write a test for this soon, and provide a fix.



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