Skip to content

Commit 08308da

Browse files
authored
Ensure matchCN thread safety when engine task parallelism > 1 (#1503)
1 parent a5bf600 commit 08308da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

runtime/binding-tls/src/main/java/io/aklivity/zilla/runtime/binding/tls/internal/identity/TlsClientX509ExtendedKeyManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public final class TlsClientX509ExtendedKeyManager extends X509ExtendedKeyManage
3838

3939
public static final Pattern COMMON_NAME_PATTERN = Pattern.compile("CN=(?<cn>[^,]+)");
4040

41-
private final Matcher matchCN = COMMON_NAME_PATTERN.matcher("");
41+
private static final ThreadLocal<Matcher> COMMON_NAME_MATCHER =
42+
ThreadLocal.withInitial(() -> COMMON_NAME_PATTERN.matcher(""));
4243

4344
private final X509ExtendedKeyManager delegate;
4445
private final boolean debug;
@@ -113,6 +114,7 @@ else if (keyTypes != null)
113114
X509Certificate[] chain = delegate.getCertificateChain(candidate);
114115
if (chain != null)
115116
{
117+
Matcher matchCN = COMMON_NAME_MATCHER.get();
116118
X500Principal subject = chain[0].getSubjectX500Principal();
117119

118120
if (subject != null &&

0 commit comments

Comments
 (0)