diff options
author | olivier lamy <olamy@apache.org> | 2017-07-31 22:16:08 +1000 |
---|---|---|
committer | olivier lamy <olamy@apache.org> | 2017-07-31 22:16:08 +1000 |
commit | c0623553f0819cb0cf0e7c7bd5897ba6e00b2fe6 (patch) | |
tree | 7a68c7c4b16bd749670fe5a4b2b1d2f3adc7798b /archiva-modules/plugins/metadata-store-jcr | |
parent | d93ae430d5b2d21f98500669eb79b64a6c38c56a (diff) | |
download | archiva-c0623553f0819cb0cf0e7c7bd5897ba6e00b2fe6.tar.gz archiva-c0623553f0819cb0cf0e7c7bd5897ba6e00b2fe6.zip |
shutdown executor service on close
Signed-off-by: olivier lamy <olamy@apache.org>
Diffstat (limited to 'archiva-modules/plugins/metadata-store-jcr')
-rw-r--r-- | archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java index e2be03f40..c02e71f76 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java @@ -77,20 +77,22 @@ public class RepositoryFactory private FileStore fileStore; + private ExecutorService executorService; + public enum StoreType { SEGMENT_FILE_TYPE, IN_MEMORY_TYPE; } - private StoreType storeType = SEGMENT_FILE_TYPE; - Path repositoryPath = Paths.get( "repository" ); + private Path repositoryPath = Paths.get( "repository" ); public Repository createRepository() throws IOException, InvalidFileStoreVersionException { + createExecutor(); NodeStore nodeStore; if ( SEGMENT_FILE_TYPE == storeType ) { @@ -199,7 +201,6 @@ public class RepositoryFactory } } ); - ExecutorService executorService = createExecutor(); StatisticsProvider statsProvider = StatisticsProvider.NOOP; int queueSize = Integer.getInteger( "queueSize", 10000 ); File indexDir = Files.createTempDirectory( "archiva_index" ).toFile(); @@ -255,6 +256,10 @@ public class RepositoryFactory { fileStore.close(); } + if (executorService != null) + { + executorService.shutdownNow(); + } } public StoreType getStoreType() @@ -294,9 +299,13 @@ public class RepositoryFactory } } - private ExecutorService createExecutor() + private void createExecutor() { - return Executors.newCachedThreadPool(); + if (executorService ==null ) + { + executorService = Executors.newCachedThreadPool(); + } + // // ThreadPoolExecutor executor = // new ThreadPoolExecutor( 0, 5, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), |