From 986a44538fff726ae0b98312dc87b80a2c6f44fb Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 7 Nov 2025 19:51:24 +0100 Subject: [PATCH] Revert "Utilize VT if possible (#381)" This reverts commit 6f0ad55ec20cdeb49b83d00466c84358b7b71c6e. --- pom.xml | 38 -------------- .../archiver/zip/ConcurrentJarCreator.java | 5 +- ...rrentJarCreatorExecutorServiceFactory.java | 51 ------------------- ...rrentJarCreatorExecutorServiceFactory.java | 38 -------------- 4 files changed, 3 insertions(+), 129 deletions(-) delete mode 100644 src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java delete mode 100644 src/main/java21/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java diff --git a/pom.xml b/pom.xml index 02e745a1..19e2b809 100644 --- a/pom.xml +++ b/pom.xml @@ -182,42 +182,4 @@ - - - jdk21 - - [21,) - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - java21 - - compile - - compile - - 21 - - ${project.basedir}/src/main/java21 - - true - - - - - - - - - plexus-release - - 21 - - - diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java b/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java index 18c6ae09..4b2e7d74 100644 --- a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreator.java @@ -23,6 +23,7 @@ import java.io.SequenceInputStream; import java.io.UncheckedIOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; import java.util.zip.Deflater; import java.util.zip.ZipEntry; @@ -117,8 +118,8 @@ public ConcurrentJarCreator(boolean compressAddedZips, int nThreads) throws IOEx manifest = createDeferred(defaultSupplier); directories = createDeferred(defaultSupplier); synchronousEntries = createDeferred(defaultSupplier); - parallelScatterZipCreator = new ParallelScatterZipCreator( - ConcurrentJarCreatorExecutorServiceFactory.createExecutorService(nThreads), defaultSupplier); + parallelScatterZipCreator = + new ParallelScatterZipCreator(Executors.newFixedThreadPool(nThreads), defaultSupplier); } /** diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java b/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java deleted file mode 100644 index b475a778..00000000 --- a/src/main/java/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java +++ /dev/null @@ -1,51 +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.codehaus.plexus.archiver.zip; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Classic (pre Java 21) implementation. Create one thread eagerly, but allow pool to scale up to provided - * number (usually set to Java reported CPU count). Apply same thread names as well. - * - * @since 4.10.1 - */ -public class ConcurrentJarCreatorExecutorServiceFactory { - private static final AtomicInteger POOL_COUNTER = new AtomicInteger(); - - static ExecutorService createExecutorService(int poolSize) { - ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); - int poolCount = POOL_COUNTER.incrementAndGet(); - AtomicInteger threadCounter = new AtomicInteger(); - ThreadFactory threadFactory = new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - Thread thread = - new Thread(threadGroup, r, "plx-arch-" + poolCount + "-" + threadCounter.incrementAndGet()); - thread.setDaemon(true); - return thread; - } - }; - return new ThreadPoolExecutor(1, poolSize, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory); - } -} diff --git a/src/main/java21/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java b/src/main/java21/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java deleted file mode 100644 index 27302a0b..00000000 --- a/src/main/java21/org/codehaus/plexus/archiver/zip/ConcurrentJarCreatorExecutorServiceFactory.java +++ /dev/null @@ -1,38 +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.codehaus.plexus.archiver.zip; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Post Java 21 implementation. Create one Virtual Thread per task execution. Apply same thread names as well. - * - * @since 4.10.1 - */ -public class ConcurrentJarCreatorExecutorServiceFactory { - private static final AtomicInteger POOL_COUNTER = new AtomicInteger(); - - static ExecutorService createExecutorService(int poolSize) { - int poolCount = POOL_COUNTER.incrementAndGet(); - AtomicInteger threadCounter = new AtomicInteger(); - return Executors.newThreadPerTaskExecutor( - Thread.ofVirtual().name("plx-arch-" + poolCount + "-" + threadCounter.incrementAndGet()).factory()); - } -}