Fix argon and balloon blocking application shutdown#151
Fix argon and balloon blocking application shutdown#151firaja merged 1 commit intoPassword4j:masterfrom
Conversation
|
Hi @phinner thank you for your awesome work! |
Spotted it in my plugin for the game Mindustry after updating all my dependencies (including password4j moving from 1.7 to 1.8). Now, after a good night, I had more time to think about the use of int minThreads = PropertyReader.readInt("global.threads.min", AVAILABLE_PROCESSORS, "The minimum number of threads is not defined");
if (minThreads < 0) {
throw new IllegalArgumentException("The minimum number of threads is negative");
}
int maxThreads = PropertyReader.readInt("global.threads.max", AVAILABLE_PROCESSORS, "The maximum number of threads is not defined");
if (maxThreads < 0) {
throw new IllegalArgumentException("The maximum number of threads is negative");
}
if (minThreads > maxThreads) {
throw new IllegalArgumentException("The minimum number of threads is above the maximum");
}
THREAD_POOL = new ThreadPoolExecutor(
minThreads,
maxThreads,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
runnable -> {
Thread thread = new Thread(THREAD_GROUP, runnable, "password4j-worker-" + THREAD_COUNTER.getAndIncrement());
thread.setDaemon(true);
return thread;
}
);Since it's essentially a new feature, this would be in 1.9, thus me asking first. |
|
I see your point, very interesting. Take in account that 95% of the time systems will use 1 algorithm with 1 configuration. |
In my case, I use one argon function for passwords and another for session tokens. |
|
Hi @phinner this is now part of |
If you set the parallelism of
Argon2FunctionorBalloonHashingFunctionabove1and that you hash something, a non daemonExecutorServicewill be created, which can block the application shutdown if there is no explicitSystem.exit.This PR fixes this by making the threads of the created
ExecutorServicedaemon.And also add names and a dedicated thread group for password4j threads, making debugging that kind of issue MUCH easier (I had to trace every thread pool creation to figure the issue out).