From 4c42c70a5178add997f705728337061eaa5a9c91 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 10 Jun 2024 18:27:21 -0400 Subject: [PATCH] Tokenizer is immutable and thread safe, so reuse it. --- .../apache/hc/client5/http/ssl/DistinguishedNameParser.java | 6 +++--- .../hc/client5/http/ssl/TestDistinguishedNameParser.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java index 0db8bffa5..21f27708d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java @@ -45,10 +45,10 @@ final class DistinguishedNameParser { private static final Tokenizer.Delimiter EQUAL_OR_COMMA_OR_PLUS = Tokenizer.delimiters('=', ',', '+'); private static final Tokenizer.Delimiter COMMA_OR_PLUS = Tokenizer.delimiters(',', '+'); - private final Tokenizer tokenParser; + private final Tokenizer tokenParser = new InternalTokenParser(); - DistinguishedNameParser() { - this.tokenParser = new InternalTokenParser(); + private DistinguishedNameParser() { + // empty } private String parseToken(final CharArrayBuffer buf, final Tokenizer.Cursor cursor, final Tokenizer.Delimiter delimiters) { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java index 26de7b993..553d57a0b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java @@ -46,7 +46,7 @@ public class TestDistinguishedNameParser { @BeforeEach public void setup() { - impl = new DistinguishedNameParser(); + impl = DistinguishedNameParser.INSTANCE; } @Test