ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [ws-wss4j] branch master updated: Improve thread safety of subclass ThreadLocalSecurityProvider. (#6)
Date Wed, 19 Feb 2020 06:43:09 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git


The following commit(s) were added to refs/heads/master by this push:
     new c890356  Improve thread safety of subclass ThreadLocalSecurityProvider. (#6)
c890356 is described below

commit c89035677973f89f331d764af44e7e46f4259d38
Author: Dehami Koswatte <dehami.deshan@gmail.com>
AuthorDate: Wed Feb 19 12:13:03 2020 +0530

    Improve thread safety of subclass ThreadLocalSecurityProvider. (#6)
    
    * Synchronize overridden methods in the subclass which are synchronized in the superclass.
    
    * Add Override annotations to the overridden methods.
---
 .../common/crypto/ThreadLocalSecurityProvider.java | 32 ++++++++++++++++------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/ThreadLocalSecurityProvider.java
b/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/ThreadLocalSecurityProvider.java
index e6cf419..a44a5d7 100644
--- a/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/ThreadLocalSecurityProvider.java
+++ b/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/ThreadLocalSecurityProvider.java
@@ -37,7 +37,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
 
     public static synchronized void install() {
         Security.insertProviderAt(new ThreadLocalSecurityProvider(),
-                                  Security.getProviders().length);
+                Security.getProviders().length);
         installed = true;
     }
 
@@ -66,28 +66,32 @@ public final class ThreadLocalSecurityProvider extends Provider {
         return PROVIDER.get();
     }
 
-    public void clear() {
+    @Override
+    public synchronized void clear() {
         Provider p = getProvider();
         if (p != null) {
             p.clear();
         }
     }
 
-    public void load(InputStream inStream) throws IOException {
+    @Override
+    public synchronized void load(InputStream inStream) throws IOException {
         Provider p = getProvider();
         if (p != null) {
             p.load(inStream);
         }
     }
 
-    public void putAll(Map<?, ?> t) {
+    @Override
+    public synchronized void putAll(Map<?, ?> t) {
         Provider p = getProvider();
         if (p != null) {
             p.putAll(t);
         }
     }
 
-    public Set<Map.Entry<Object, Object>> entrySet() {
+    @Override
+    public synchronized Set<Map.Entry<Object, Object>> entrySet() {
         Provider p = getProvider();
         if (p != null) {
             return p.entrySet();
@@ -96,6 +100,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public Set<Object> keySet() {
         Provider p = getProvider();
         if (p != null) {
@@ -105,6 +110,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public Collection<Object> values() {
         Provider p = getProvider();
         if (p != null) {
@@ -114,7 +120,8 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
-    public Object put(Object key, Object value) {
+    @Override
+    public synchronized Object put(Object key, Object value) {
         Provider p = getProvider();
         if (p != null) {
             return p.put(key, value);
@@ -123,7 +130,8 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
-    public Object remove(Object key) {
+    @Override
+    public synchronized Object remove(Object key) {
         Provider p = getProvider();
         if (p != null) {
             return p.remove(key);
@@ -132,6 +140,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public Object get(Object key) {
         Provider p = getProvider();
         if (p != null) {
@@ -141,6 +150,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public Enumeration<Object> keys() {
         Provider p = getProvider();
         if (p != null) {
@@ -150,6 +160,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public Enumeration<Object> elements() {
         Provider p = getProvider();
         if (p != null) {
@@ -159,6 +170,7 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
+    @Override
     public String getProperty(String key) {
         Provider p = getProvider();
         if (p != null) {
@@ -168,7 +180,8 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
-    public Service getService(String type, String algorithm) {
+    @Override
+    public synchronized Service getService(String type, String algorithm) {
         Provider p = getProvider();
         if (p != null) {
             return p.getService(type, algorithm);
@@ -177,7 +190,8 @@ public final class ThreadLocalSecurityProvider extends Provider {
         }
     }
 
-    public Set<Service> getServices() {
+    @Override
+    public synchronized Set<Service> getServices() {
         Provider p = getProvider();
         if (p != null) {
             return p.getServices();


Mime
View raw message