You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2020/01/22 08:19:34 UTC
[wicket] branch csp updated: WICKET-6730: remove the need for
synchronized
This is an automated email from the ASF dual-hosted git repository.
papegaaij pushed a commit to branch csp
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/csp by this push:
new 29fc189 WICKET-6730: remove the need for synchronized
29fc189 is described below
commit 29fc189a4345aaa1adcfa0fe0dde04f928ed0a34
Author: Emond Papegaaij <em...@topicus.nl>
AuthorDate: Wed Jan 22 09:19:16 2020 +0100
WICKET-6730: remove the need for synchronized
The ISecureRandomSupplier is used from request threads and can
be needed several times per request. Synchronization will make
this an application wide bottleneck, which is a bad thing.
---
.../java/org/apache/wicket/settings/SecuritySettings.java | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java b/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
index 6e225a4..9556f98 100644
--- a/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
+++ b/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
@@ -59,7 +59,7 @@ public class SecuritySettings
private ICryptFactory cryptFactory;
/** supplier of random data and SecureRandom */
- private ISecureRandomSupplier randomSupplier;
+ private ISecureRandomSupplier randomSupplier = new DefaultSecureRandomSupplier();
/**
* Whether mounts should be enforced. If {@code true}, requests for a page will be
@@ -120,17 +120,13 @@ public class SecuritySettings
}
/**
- * Returns the {@link ISecureRandomSupplier} to use for secure random data. If no supplier is
- * set, a {@link DefaultSecureRandomSupplier} is instantiated.
+ * Returns the {@link ISecureRandomSupplier} to use for secure random data. If no custom
+ * supplier is set, a {@link DefaultSecureRandomSupplier} is used.
*
* @return The {@link ISecureRandomSupplier} to use for secure random data.
*/
- public synchronized ISecureRandomSupplier getRandomSupplier()
+ public ISecureRandomSupplier getRandomSupplier()
{
- if (randomSupplier == null)
- {
- randomSupplier = new DefaultSecureRandomSupplier();
- }
return randomSupplier;
}
@@ -193,7 +189,7 @@ public class SecuritySettings
* The new supplier, must not be null.
* @return {@code this} object for chaining
*/
- public synchronized SecuritySettings setRandomSupplier(ISecureRandomSupplier randomSupplier)
+ public SecuritySettings setRandomSupplier(ISecureRandomSupplier randomSupplier)
{
Args.notNull(randomSupplier, "randomSupplier");
this.randomSupplier = randomSupplier;