Skip to content

Commit 582869e

Browse files
authored
Replace ThreadLocal Collator with instance Collator (#48037)
1 parent 78fe639 commit 582869e

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/StorageSharedKeyCredential.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
public final class StorageSharedKeyCredential {
3535
private static final ClientLogger LOGGER = new ClientLogger(StorageSharedKeyCredential.class);
3636

37-
// Previous design used a constant for the ROOT_COLLATOR. This runs into performance issues as the ROOT Collator
38-
// can have the comparison method synchronized. In highly threaded environments this can result in threads waiting
39-
// to enter the synchronized block.
40-
private static final ThreadLocal<Collator> THREAD_LOCAL_COLLATOR
41-
= ThreadLocal.withInitial(() -> Collator.getInstance(Locale.ROOT));
42-
4337
private static final Context LOG_STRING_TO_SIGN_CONTEXT = new Context(Constants.STORAGE_LOG_STRING_TO_SIGN, true);
4438

4539
// Pieces of the connection string that are needed.
@@ -189,7 +183,7 @@ private String buildStringToSign(URL requestURL, String httpMethod, HttpHeaders
189183
String dateHeader
190184
= (headers.getValue(X_MS_DATE) != null) ? "" : getStandardHeaderValue(headers, HttpHeaderName.DATE);
191185

192-
Collator collator = THREAD_LOCAL_COLLATOR.get();
186+
Collator collator = Collator.getInstance(Locale.ROOT);
193187
String stringToSign
194188
= String.join("\n", httpMethod, getStandardHeaderValue(headers, HttpHeaderName.CONTENT_ENCODING),
195189
getStandardHeaderValue(headers, HttpHeaderName.CONTENT_LANGUAGE), contentLength,

0 commit comments

Comments
 (0)