[java-support] 01/01: JSPT-97 - Correctly synchronize component base classes

Ian Young ian at iay.org.uk
Wed Jun 3 14:08:42 UTC 2020


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch dev/JSPT-97
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=dff83d9468a8514c54a60a2df2c4620a5713a03d

commit dff83d9468a8514c54a60a2df2c4620a5713a03d
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Jun 3 15:08:35 2020 +0100

    JSPT-97 - Correctly synchronize component base classes
    
    https://issues.shibboleth.net/jira/browse/JSPT-97
---
 .../component/AbstractIdentifiedInitializableComponent.java    |  7 ++++---
 .../java/support/component/AbstractInitializableComponent.java | 10 ++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/main/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiedInitializableComponent.java b/src/main/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiedInitializableComponent.java
index 4cd7c3e..3ab71e7 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiedInitializableComponent.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiedInitializableComponent.java
@@ -19,6 +19,7 @@ package net.shibboleth.utilities.java.support.component;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+import javax.annotation.concurrent.GuardedBy;
 
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
@@ -32,10 +33,10 @@ public abstract class AbstractIdentifiedInitializableComponent extends AbstractI
         IdentifiedComponent {
 
     /** The unique identifier for this component. */
-    @Nullable @NonnullAfterInit private String id;
+    @Nullable @NonnullAfterInit @GuardedBy("this") private String id;
 
     /** {@inheritDoc} */
-    @Nullable @NonnullAfterInit public String getId() {
+    @Nullable @NonnullAfterInit public synchronized String getId() {
         return id;
     }
 
@@ -44,7 +45,7 @@ public abstract class AbstractIdentifiedInitializableComponent extends AbstractI
      * 
      * @param componentId ID of the component
      */
-    protected void setId(@Nonnull @NotEmpty final String componentId) {
+    protected synchronized void setId(@Nonnull @NotEmpty final String componentId) {
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
 
         id = Constraint.isNotNull(StringSupport.trimOrNull(componentId), "Component ID can not be null or empty");
diff --git a/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java b/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java
index 3c59683..553f2de 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java
@@ -17,25 +17,27 @@
 
 package net.shibboleth.utilities.java.support.component;
 
+import javax.annotation.concurrent.GuardedBy;
+
 /** Base class for things that implement {@link DestructableComponent} and {@link InitializableComponent}. */
 public abstract class AbstractInitializableComponent implements DestructableComponent,
         InitializableComponent {
 
     /** Whether this component has been destroyed. */
-    private boolean isDestroyed;
+    @GuardedBy("this") private boolean isDestroyed;
 
     /** Whether this component has been initialized. */
-    private boolean isInitialized;
+    @GuardedBy("this") private boolean isInitialized;
 
     /** {@inheritDoc} */
     @Override
-    public final boolean isDestroyed() {
+    public final synchronized boolean isDestroyed() {
         return isDestroyed;
     }
 
     /** {@inheritDoc} */
     @Override
-    public boolean isInitialized() {
+    public synchronized boolean isInitialized() {
         return isInitialized;
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list