File tree Expand file tree Collapse file tree 3 files changed +6
-9
lines changed
main/java/com/auth0/android/dpop
test/java/com/auth0/android/dpop Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import com.auth0.android.request.HttpMethod
99import com.auth0.android.request.getErrorBody
1010import okhttp3.Response
1111import java.lang.reflect.Modifier.PRIVATE
12+ import java.util.concurrent.atomic.AtomicReference
1213
1314
1415/* *
@@ -102,12 +103,11 @@ public class DPoP(context: Context) {
102103 private const val AUTHORIZATION_HEADER = " Authorization"
103104 private const val NONCE_HEADER = " DPoP-Nonce"
104105
105- @Volatile
106106 @VisibleForTesting(otherwise = PRIVATE )
107- internal var _auth0Nonce : String? = null
107+ internal val _auth0Nonce : AtomicReference < String ?> = AtomicReference ( null )
108108
109109 public val auth0Nonce: String?
110- get() = _auth0Nonce
110+ get() = _auth0Nonce .get()
111111
112112 /* *
113113 * Stores the nonce value from the Okhttp3 [Response] headers.
@@ -127,9 +127,7 @@ public class DPoP(context: Context) {
127127 @JvmStatic
128128 internal fun storeNonce (response : Response ) {
129129 response.headers[NONCE_HEADER ]?.let {
130- synchronized(this ) {
131- _auth0Nonce = it
132- }
130+ _auth0Nonce .set(it)
133131 }
134132 }
135133
@@ -220,7 +218,7 @@ public class DPoP(context: Context) {
220218 @JvmStatic
221219 public fun clearKeyPair () {
222220 DPoPUtil .clearKeyPair()
223- _auth0Nonce = null
221+ _auth0Nonce .set( null )
224222 }
225223 }
226224}
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ internal object DPoPUtil {
2929
3030
3131 @VisibleForTesting(otherwise = VisibleForTesting .PRIVATE )
32- @Volatile
3332 internal var keyStore = DPoPKeyStore ()
3433
3534
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public class DPoPTest {
5151 whenever(mockContext.applicationContext).thenReturn(mockContext)
5252 dPoP = DPoP (mockContext)
5353
54- DPoP ._auth0Nonce = null
54+ DPoP ._auth0Nonce .set( null )
5555
5656 DPoPUtil .keyStore = mockKeyStore
5757 }
You can’t perform that action at this time.
0 commit comments