5959import java .net .SocketException ;
6060import java .util .*;
6161import java .util .concurrent .CompletableFuture ;
62+ import java .util .concurrent .ConcurrentHashMap ;
6263
6364public class PlayerConnectionImpl extends SimpleChannelInboundHandler <ServerboundPacket > implements PlayerConnection {
6465
@@ -124,7 +125,7 @@ public void sendStatusResponse(final @NotNull StatusResponse response) {
124125 }
125126 CompletableFuture <byte []> future ;
126127 if (this .pendingCookies == null ) {
127- this .pendingCookies = new HashMap <>();
128+ this .pendingCookies = new ConcurrentHashMap <>();
128129 future = null ;
129130 } else {
130131 future = this .pendingCookies .get (cookieKey );
@@ -153,10 +154,11 @@ public void storeCookie(final @NotNull String cookieKey, final byte @NotNull []
153154
154155 @ Override
155156 public void handleCookieResponse (final @ NotNull String cookieKey , final byte @ Nullable [] payload ) {
156- if (this .pendingCookies == null ) {
157+ final Map <String , CompletableFuture <byte []>> pendingCookies = this .pendingCookies ;
158+ if (pendingCookies == null ) {
157159 return ;
158160 }
159- final CompletableFuture <byte []> future = this . pendingCookies .get (cookieKey );
161+ final CompletableFuture <byte []> future = pendingCookies .get (cookieKey );
160162 if (future == null ) {
161163 return ;
162164 }
@@ -165,7 +167,8 @@ public void handleCookieResponse(final @NotNull String cookieKey, final byte @Nu
165167
166168 @ Override
167169 public @ NotNull Map <String , CompletableFuture <byte []>> getPendingCookies () {
168- return this .pendingCookies != null ? Collections .unmodifiableMap (this .pendingCookies ) : Map .of ();
170+ final Map <String , CompletableFuture <byte []>> pendingCookies = this .pendingCookies ;
171+ return pendingCookies != null ? Collections .unmodifiableMap (pendingCookies ) : Map .of ();
169172 }
170173
171174 @ Override
0 commit comments