1616 */
1717package org .privacyidea ;
1818
19+ import java .io .Closeable ;
20+ import java .io .IOException ;
1921import java .util .Arrays ;
2022import java .util .Collections ;
2123import java .util .LinkedHashMap ;
2628import java .util .concurrent .BlockingQueue ;
2729import java .util .concurrent .Callable ;
2830import java .util .concurrent .ExecutionException ;
29- import java .util .concurrent .ExecutorService ;
3031import java .util .concurrent .Future ;
3132import java .util .concurrent .ThreadPoolExecutor ;
3233import java .util .concurrent .TimeUnit ;
5455 * This is the main class. It implements the common endpoints such as /validate/check as methods for easy usage.
5556 * To create an instance of this class, use the nested PrivacyIDEA.Builder class.
5657 */
57- public class PrivacyIDEA
58+ public class PrivacyIDEA implements Closeable
5859{
5960 private final PIConfig configuration ;
6061 private final IPILogger log ;
6162 private final IPISimpleLogger simpleLog ;
6263 private final Endpoint endpoint ;
6364 // Thread pool for connections
64- private final BlockingQueue <Runnable > queue = new ArrayBlockingQueue <>(100 );
65- private final ExecutorService threadPool = new ThreadPoolExecutor (20 , 20 , 10 , TimeUnit .SECONDS , queue );
65+ private final BlockingQueue <Runnable > queue = new ArrayBlockingQueue <>(1000 );
66+ private final ThreadPoolExecutor threadPool = new ThreadPoolExecutor (20 , 20 , 10 , TimeUnit .SECONDS , queue );
6667 final JSONParser parser ;
6768 // Responses from these endpoints will not be logged. The list can be overwritten.
6869 private List <String > logExcludedEndpoints = Arrays .asList (PIConstants .ENDPOINT_AUTH ,
@@ -75,6 +76,7 @@ private PrivacyIDEA(PIConfig configuration, IPILogger logger, IPISimpleLogger si
7576 this .configuration = configuration ;
7677 this .endpoint = new Endpoint (this );
7778 this .parser = new JSONParser (this );
79+ this .threadPool .allowCoreThreadTimeOut (true );
7880 }
7981
8082 /**
@@ -535,6 +537,12 @@ else if (this.simpleLog != null)
535537 }
536538 }
537539
540+ @ Override
541+ public void close () throws IOException
542+ {
543+ this .threadPool .shutdown ();
544+ }
545+
538546 /**
539547 * Get a new Builder to create a PrivacyIDEA instance.
540548 *
0 commit comments