Code clean-up
Motivation: It is less confusing not to spread Thread.interrupt() calls. Modification: - Comments - Move generatorThread.interrupt() to where currentThread.interrupt() is triggered Result: Code that is easier to read
This commit is contained in:
parent
bdab831ba5
commit
b4bc47e280
@ -131,7 +131,6 @@ public class ThreadLocalRandom extends Random {
|
|||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
interrupted = true;
|
interrupted = true;
|
||||||
generatorThread.interrupt();
|
|
||||||
logger.warn("Failed to generate a seed from SecureRandom due to an InterruptedException.");
|
logger.warn("Failed to generate a seed from SecureRandom due to an InterruptedException.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -144,8 +143,12 @@ public class ThreadLocalRandom extends Random {
|
|||||||
ThreadLocalRandom.initialSeedUniquifier = initialSeedUniquifier;
|
ThreadLocalRandom.initialSeedUniquifier = initialSeedUniquifier;
|
||||||
|
|
||||||
if (interrupted) {
|
if (interrupted) {
|
||||||
// restore interrupt status because we don't know how to/don't need to handle it here
|
// Restore the interrupt status because we don't know how to/don't need to handle it here.
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
|
||||||
|
// Interrupt the generator thread if it's still running,
|
||||||
|
// in the hope that the SecureRandom provider raises an exception on interruption.
|
||||||
|
generatorThread.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user