You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2026/04/02 11:06:26 UTC
(jackrabbit-oak) branch trunk updated: OAK-12169: remove org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory (#2829)
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new ab7ba1eeda OAK-12169: remove org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory (#2829)
ab7ba1eeda is described below
commit ab7ba1eedabf05b7311a6c27030c625a87c1a296
Author: Julian Reschke <re...@apache.org>
AuthorDate: Thu Apr 2 13:06:21 2026 +0200
OAK-12169: remove org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory (#2829)
---
.../oak/spi/blob/data/AbstractBackend.java | 9 ++---
.../oak/spi/blob/data/CachingDataStore.java | 6 +--
.../oak/spi/blob/data/util/NamedThreadFactory.java | 45 ----------------------
.../oak/spi/blob/data/util/package-info.java | 23 -----------
.../oak/spi/blob/data/TestLocalCache.java | 4 +-
5 files changed, 9 insertions(+), 78 deletions(-)
diff --git a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/AbstractBackend.java b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/AbstractBackend.java
index 27ce2de629..b0ae9dfe3a 100644
--- a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/AbstractBackend.java
+++ b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/AbstractBackend.java
@@ -17,12 +17,11 @@
// copied from Apache Jackrabbit jackrabbit-data module; original class org.apache.jackrabbit.core.data.AbstractBackend
package org.apache.jackrabbit.oak.spi.blob.data;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory;
/**
* Abstract Backend which has a reference to the underlying {@link CachingDataStore} and is
@@ -169,8 +168,8 @@ public abstract class AbstractBackend implements Backend {
Executor asyncExecutor;
if (dataStore.getAsyncUploadLimit() > 0 && getAsyncWritePoolSize() > 0) {
- asyncExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(getAsyncWritePoolSize(),
- new NamedThreadFactory(getClass().getSimpleName() + "-write-worker"));
+ asyncExecutor = Executors.newFixedThreadPool(getAsyncWritePoolSize(),
+ BasicThreadFactory.builder().namingPattern(getClass().getSimpleName() + "-write-worker-%d").build());
} else {
asyncExecutor = new ImmediateExecutor();
}
diff --git a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/CachingDataStore.java b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/CachingDataStore.java
index fb2f7f4d3e..26d5f74bc5 100644
--- a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/CachingDataStore.java
+++ b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/CachingDataStore.java
@@ -49,7 +49,7 @@ import javax.jcr.RepositoryException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -356,7 +356,7 @@ public abstract class CachingDataStore extends AbstractDataStore implements
}
}
downloadExecService = Executors.newFixedThreadPool(5,
- new NamedThreadFactory("backend-file-download-worker"));
+ BasicThreadFactory.builder().namingPattern("backend-file-download-worker-%d").build());
cache = new LocalCache(path, tmpDir.getAbsolutePath(), cacheSize,
cachePurgeTrigFactor, cachePurgeResizeFactor, asyncWriteCache);
/*
@@ -1282,7 +1282,7 @@ public abstract class CachingDataStore extends AbstractDataStore implements
long startTime = System.currentTimeMillis();
LOG.info(" Uploading [{}] using [{}] threads.", files.size(), threads);
ExecutorService executor = Executors.newFixedThreadPool(threads,
- new NamedThreadFactory("backend-file-upload-worker"));
+ BasicThreadFactory.builder().namingPattern("backend-file-upload-worker-%d").build());
int partitionSize = files.size() / (threads);
int startIndex = 0;
int endIndex = partitionSize;
diff --git a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/NamedThreadFactory.java b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/NamedThreadFactory.java
deleted file mode 100644
index 291d368cfa..0000000000
--- a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/NamedThreadFactory.java
+++ /dev/null
@@ -1,45 +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.
- */
-// copied from Apache Jackrabbit jackrabbit-data module; original class org.apache.jackrabbit.core.data.util.NamedThreadFactory
-
-package org.apache.jackrabbit.oak.spi.blob.data.util;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * This class extends {@link ThreadFactory} to creates named threads.
- */
-public class NamedThreadFactory implements ThreadFactory {
-
- private AtomicInteger threadCount = new AtomicInteger(1);
-
- String threadPrefixName;
-
- public NamedThreadFactory(String threadPrefixName) {
- super();
- this.threadPrefixName = threadPrefixName;
- }
-
- public Thread newThread(Runnable r) {
- Thread thread = new Thread(r);
- thread.setContextClassLoader(getClass().getClassLoader());
- thread.setName(threadPrefixName + "-" + threadCount.getAndIncrement());
- return thread;
- }
-
-}
diff --git a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/package-info.java b/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/package-info.java
deleted file mode 100755
index de67cc68d7..0000000000
--- a/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/data/util/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-
-@Version("1.0.0")
-@Internal
-package org.apache.jackrabbit.oak.spi.blob.data.util;
-
-import org.apache.jackrabbit.oak.commons.annotations.Internal;
-import org.osgi.annotation.versioning.Version;
\ No newline at end of file
diff --git a/oak-blob/src/test/java/org/apache/jackrabbit/oak/spi/blob/data/TestLocalCache.java b/oak-blob/src/test/java/org/apache/jackrabbit/oak/spi/blob/data/TestLocalCache.java
index 8d6dc11f72..3a447adf91 100644
--- a/oak-blob/src/test/java/org/apache/jackrabbit/oak/spi/blob/data/TestLocalCache.java
+++ b/oak-blob/src/test/java/org/apache/jackrabbit/oak/spi/blob/data/TestLocalCache.java
@@ -33,7 +33,7 @@ import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.oak.spi.blob.data.util.NamedThreadFactory;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -345,7 +345,7 @@ public class TestLocalCache extends TestCase {
cache.close();
ExecutorService executor = Executors.newFixedThreadPool(10,
- new NamedThreadFactory("localcache-store-worker"));
+ BasicThreadFactory.builder().namingPattern("localcache-store-worker-%d").build());
cache = new LocalCache(cacheDirPath, tempDirPath, 10000000, 0.95,
0.70, pendingFiles);
executor.execute(new StoreWorker(cache, byteMap));