[java-shib-shared] branch main updated: Add synchronization around scheme/port map.
Scott Cantor
cantor.2 at osu.edu
Mon Apr 24 20:09:53 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=35be577fd76b281aacc35d6966d93a1ed5acc28f
The following commit(s) were added to refs/heads/main by this push:
new 35be577f Add synchronization around scheme/port map.
35be577f is described below
commit 35be577fd76b281aacc35d6966d93a1ed5acc28f
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Apr 24 16:09:50 2023 -0400
Add synchronization around scheme/port map.
---
.../net/shibboleth/shared/net/SimpleURLCanonicalizer.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/shib-networking/src/main/java/net/shibboleth/shared/net/SimpleURLCanonicalizer.java b/shib-networking/src/main/java/net/shibboleth/shared/net/SimpleURLCanonicalizer.java
index bfa326a4..75b002ca 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/net/SimpleURLCanonicalizer.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/net/SimpleURLCanonicalizer.java
@@ -42,7 +42,7 @@ import net.shibboleth.shared.primitive.StringSupport;
public final class SimpleURLCanonicalizer {
/** The scheme-to-port mapping data. */
- private static Map<String, Integer> schemePortMap = new HashMap<>();
+ @Nonnull private static final Map<String, Integer> SCHEME_PORT_MAP = new HashMap<>();
/** Constructor to prevent instantiation. */
private SimpleURLCanonicalizer() {}
@@ -57,7 +57,9 @@ public final class SimpleURLCanonicalizer {
final String trimmedScheme = Constraint.isNotNull(StringSupport.trimOrNull(scheme), "Scheme cannot be null");
Constraint.isNotNull(port, "Port cannot be null");
- schemePortMap.put(trimmedScheme.toLowerCase(), port);
+ synchronized(SCHEME_PORT_MAP) {
+ SCHEME_PORT_MAP.put(trimmedScheme.toLowerCase(), port);
+ }
}
/**
@@ -68,7 +70,9 @@ public final class SimpleURLCanonicalizer {
public static void deregisterSchemePortMapping(@Nonnull final String scheme) {
final String trimmedScheme = Constraint.isNotNull(StringSupport.trimOrNull(scheme), "Scheme cannot be null");
- schemePortMap.remove(trimmedScheme.toLowerCase());
+ synchronized(SCHEME_PORT_MAP) {
+ SCHEME_PORT_MAP.remove(trimmedScheme.toLowerCase());
+ }
}
/**
@@ -80,7 +84,9 @@ public final class SimpleURLCanonicalizer {
@Nullable public static Integer getRegisteredPort(@Nonnull @NotEmpty final String scheme) {
final String trimmedScheme = Constraint.isNotNull(StringSupport.trimOrNull(scheme), "Scheme cannot be null");
- return schemePortMap.get(trimmedScheme.toLowerCase());
+ synchronized(SCHEME_PORT_MAP) {
+ return SCHEME_PORT_MAP.get(trimmedScheme.toLowerCase());
+ }
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list