This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch CAMEL-22996-dropJava17
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6ae59c57a9ab74d45fdd0bc3b7dde8ba001ae3cd
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Fri Oct 16 09:44:27 2026 +0200

    CAMEL-22996: promote java21 CamelThreadFactory to main source tree
    
    Co-authored-by: IBM Bob 2.2.1
---
 core/camel-util/pom.xml                            | 47 ------------
 .../camel/util/concurrent/CamelThreadFactory.java  | 35 +++++++--
 .../camel/util/concurrent/CamelThreadFactory.java  | 87 ----------------------
 3 files changed, 29 insertions(+), 140 deletions(-)

diff --git a/core/camel-util/pom.xml b/core/camel-util/pom.xml
index ac2fcea60d31..c93237e25706 100644
--- a/core/camel-util/pom.xml
+++ b/core/camel-util/pom.xml
@@ -278,53 +278,6 @@
                 </plugins>
             </build>
         </profile>
-        <profile>
-            <id>java-21-sources</id>
-            <activation>
-                <jdk>[21,)</jdk>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-compiler-plugin</artifactId>
-                        <version>${maven-compiler-plugin-version}</version>
-                        <executions>
-                            <execution>
-                                <id>default-compile</id>
-                                <phase>compile</phase>
-                                <goals>
-                                    <goal>compile</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>compile-java-21</id>
-                                <phase>compile</phase>
-                                <goals>
-                                    <goal>compile</goal>
-                                </goals>
-                                <configuration>
-                                    <release>21</release>
-                                    
<compileSourceRoots>${project.basedir}/src/main/java21</compileSourceRoots>
-                                    
<multiReleaseOutput>true</multiReleaseOutput>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-jar-plugin</artifactId>
-                        <configuration>
-                            <archive>
-                                <manifestEntries>
-                                    <Multi-Release>true</Multi-Release>
-                                </manifestEntries>
-                            </archive>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
         <profile>
             <id>java-25-sources</id>
             <activation>
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/concurrent/CamelThreadFactory.java
 
b/core/camel-util/src/main/java/org/apache/camel/util/concurrent/CamelThreadFactory.java
index 638fcf1b399d..4bb630479974 100644
--- 
a/core/camel-util/src/main/java/org/apache/camel/util/concurrent/CamelThreadFactory.java
+++ 
b/core/camel-util/src/main/java/org/apache/camel/util/concurrent/CamelThreadFactory.java
@@ -20,9 +20,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Thread factory which creates threads supporting a naming pattern. On JDK 
21+, this factory creates virtual threads
- * when the System property {@code camel.threads.virtual.enabled} is set to 
{@code true}. On JDK 17, only platform
- * threads are available.
+ * Thread factory which creates threads supporting a naming pattern. The 
factory creates virtual threads in case the
+ * System property {@code camel.threads.virtual.enabled} set to {@code true}.
  */
 public final class CamelThreadFactory implements ThreadFactoryTypeAware {
     private static final Logger LOG = 
LoggerFactory.getLogger(CamelThreadFactory.class);
@@ -30,24 +29,25 @@ public final class CamelThreadFactory implements 
ThreadFactoryTypeAware {
     private final String pattern;
     private final String name;
     private final boolean daemon;
+    private final ThreadFactoryType threadType;
 
     public CamelThreadFactory(String pattern, String name, boolean daemon) {
         this.pattern = pattern;
         this.name = name;
         this.daemon = daemon;
+        this.threadType = daemon ? ThreadFactoryType.current() : 
ThreadFactoryType.PLATFORM;
     }
 
     @Override
     public boolean isVirtual() {
-        return false;
+        return threadType == ThreadFactoryType.VIRTUAL;
     }
 
     @Override
     public Thread newThread(Runnable runnable) {
         String threadName = ThreadHelper.resolveThreadName(pattern, name);
 
-        Thread answer = new Thread(runnable, threadName);
-        answer.setDaemon(daemon);
+        Thread answer = threadType.newThread(threadName, daemon, runnable);
 
         LOG.trace("Created thread[{}] -> {}", threadName, answer);
         return answer;
@@ -61,4 +61,27 @@ public final class CamelThreadFactory implements 
ThreadFactoryTypeAware {
     public String toString() {
         return "CamelThreadFactory[" + name + "]";
     }
+
+    private enum ThreadFactoryType {
+        PLATFORM {
+            Thread.Builder newThreadBuilder(String threadName, boolean daemon) 
{
+                return Thread.ofPlatform().name(threadName).daemon(daemon);
+            }
+        },
+        VIRTUAL {
+            Thread.Builder newThreadBuilder(String threadName, boolean daemon) 
{
+                return Thread.ofVirtual().name(threadName);
+            }
+        };
+
+        Thread newThread(String threadName, boolean daemon, Runnable runnable) 
{
+            return newThreadBuilder(threadName, daemon).unstarted(runnable);
+        }
+
+        abstract Thread.Builder newThreadBuilder(String threadName, boolean 
daemon);
+
+        static ThreadFactoryType current() {
+            return ThreadType.current() == ThreadType.VIRTUAL ? VIRTUAL : 
PLATFORM;
+        }
+    }
 }
diff --git 
a/core/camel-util/src/main/java21/org/apache/camel/util/concurrent/CamelThreadFactory.java
 
b/core/camel-util/src/main/java21/org/apache/camel/util/concurrent/CamelThreadFactory.java
deleted file mode 100644
index 4bb630479974..000000000000
--- 
a/core/camel-util/src/main/java21/org/apache/camel/util/concurrent/CamelThreadFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.util.concurrent;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Thread factory which creates threads supporting a naming pattern. The 
factory creates virtual threads in case the
- * System property {@code camel.threads.virtual.enabled} set to {@code true}.
- */
-public final class CamelThreadFactory implements ThreadFactoryTypeAware {
-    private static final Logger LOG = 
LoggerFactory.getLogger(CamelThreadFactory.class);
-
-    private final String pattern;
-    private final String name;
-    private final boolean daemon;
-    private final ThreadFactoryType threadType;
-
-    public CamelThreadFactory(String pattern, String name, boolean daemon) {
-        this.pattern = pattern;
-        this.name = name;
-        this.daemon = daemon;
-        this.threadType = daemon ? ThreadFactoryType.current() : 
ThreadFactoryType.PLATFORM;
-    }
-
-    @Override
-    public boolean isVirtual() {
-        return threadType == ThreadFactoryType.VIRTUAL;
-    }
-
-    @Override
-    public Thread newThread(Runnable runnable) {
-        String threadName = ThreadHelper.resolveThreadName(pattern, name);
-
-        Thread answer = threadType.newThread(threadName, daemon, runnable);
-
-        LOG.trace("Created thread[{}] -> {}", threadName, answer);
-        return answer;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public String toString() {
-        return "CamelThreadFactory[" + name + "]";
-    }
-
-    private enum ThreadFactoryType {
-        PLATFORM {
-            Thread.Builder newThreadBuilder(String threadName, boolean daemon) 
{
-                return Thread.ofPlatform().name(threadName).daemon(daemon);
-            }
-        },
-        VIRTUAL {
-            Thread.Builder newThreadBuilder(String threadName, boolean daemon) 
{
-                return Thread.ofVirtual().name(threadName);
-            }
-        };
-
-        Thread newThread(String threadName, boolean daemon, Runnable runnable) 
{
-            return newThreadBuilder(threadName, daemon).unstarted(runnable);
-        }
-
-        abstract Thread.Builder newThreadBuilder(String threadName, boolean 
daemon);
-
-        static ThreadFactoryType current() {
-            return ThreadType.current() == ThreadType.VIRTUAL ? VIRTUAL : 
PLATFORM;
-        }
-    }
-}

Reply via email to