@@ -119,11 +119,11 @@ public class BfDependencyCollector extends DependencyCollectorDelegate {
119
119
public static final String CONFIG_PROP_THREADS = CONFIG_PROPS_PREFIX + "threads" ;
120
120
121
121
/**
122
- * The default value for {@link #CONFIG_PROP_THREADS}, default value {@code Runtime.getRuntime().availableProcessors()} .
122
+ * The default value for {@link #CONFIG_PROP_THREADS}, default value 5 .
123
123
*
124
124
* @since 1.9.0
125
125
*/
126
- public static final int DEFAULT_THREADS = Runtime . getRuntime (). availableProcessors () ;
126
+ public static final int DEFAULT_THREADS = 5 ;
127
127
128
128
@ Inject
129
129
public BfDependencyCollector (
@@ -470,28 +470,19 @@ private ArtifactDescriptorResult resolveDescriptorForVersion(
470
470
}
471
471
472
472
static class ParallelDescriptorResolver implements Closeable {
473
- private static volatile ExecutorService executorService ;
473
+ private final ExecutorService executorService ;
474
474
475
475
/**
476
476
* Artifact ID -> Future of DescriptorResolutionResult
477
477
*/
478
478
private final Map <String , Future <DescriptorResolutionResult >> results = new ConcurrentHashMap <>(256 );
479
479
480
480
ParallelDescriptorResolver (int threads ) {
481
- if (executorService == null ) {
482
- synchronized (ParallelDescriptorResolver .class ) {
483
- if (executorService == null ) {
484
- // create only once, so that we can reuse it across multiple instances of this class
485
- // and avoid creating too many threads / recreating it for too many times
486
- executorService = ExecutorUtils .threadPool (
487
- threads , ParallelDescriptorResolver .class .getSimpleName () + "-" );
488
- }
489
- }
490
- }
481
+ this .executorService = ExecutorUtils .threadPool (threads , getClass ().getSimpleName () + "-" );
491
482
}
492
483
493
484
void resolveDescriptors (Artifact artifact , Callable <DescriptorResolutionResult > callable ) {
494
- results .computeIfAbsent (ArtifactIdUtils .toId (artifact ), key -> executorService .submit (callable ));
485
+ results .computeIfAbsent (ArtifactIdUtils .toId (artifact ), key -> this . executorService .submit (callable ));
495
486
}
496
487
497
488
void cacheVersionRangeDescriptor (Artifact artifact , DescriptorResolutionResult resolutionResult ) {
@@ -503,7 +494,9 @@ Future<DescriptorResolutionResult> find(Artifact artifact) {
503
494
}
504
495
505
496
@ Override
506
- public void close () {}
497
+ public void close () {
498
+ executorService .shutdown ();
499
+ }
507
500
}
508
501
509
502
static class DoneFuture <V > implements Future <V > {
0 commit comments