From 5d2481a2b1b0db859e04456205851e4e3b4bfc93 Mon Sep 17 00:00:00 2001 From: duke Date: Fri, 12 Jul 2024 06:29:13 +0000 Subject: [PATCH] Backport 881517586d7b6d26c5589c3459902eb964ce9030 --- .../classes/sun/net/httpserver/ServerImpl.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java index 5555294cc27..fe63149f765 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java @@ -54,10 +54,10 @@ import java.nio.channels.SocketChannel; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.Timer; @@ -161,7 +161,7 @@ class ServerImpl { logger.log (Level.DEBUG, "MAX_REQ_TIME: "+MAX_REQ_TIME); logger.log (Level.DEBUG, "MAX_RSP_TIME: "+MAX_RSP_TIME); } - events = new LinkedList(); + events = new ArrayList<>(); logger.log (Level.DEBUG, "HttpServer created "+protocol+" "+ addr); } @@ -428,8 +428,7 @@ private void handleEvent (Event r) { } } - final LinkedList connsToRegister = - new LinkedList(); + final ArrayList connsToRegister = new ArrayList<>(); void reRegister (HttpConnection c) { /* re-register with selector */ @@ -454,7 +453,7 @@ public void run() { synchronized (lolock) { if (events.size() > 0) { list = events; - events = new LinkedList(); + events = new ArrayList<>(); } } @@ -985,7 +984,7 @@ void responseCompleted (HttpConnection c) { */ class IdleTimeoutTask extends TimerTask { public void run () { - LinkedList toClose = new LinkedList(); + ArrayList toClose = new ArrayList<>(); final long currentTime = System.currentTimeMillis(); synchronized (idleConnections) { final Iterator it = idleConnections.iterator(); @@ -1026,7 +1025,7 @@ class ReqRspTimeoutTask extends TimerTask { // runs every TIMER_MILLIS public void run () { - LinkedList toClose = new LinkedList(); + ArrayList toClose = new ArrayList<>(); final long currentTime = System.currentTimeMillis(); synchronized (reqConnections) { if (MAX_REQ_TIME != -1) { @@ -1043,7 +1042,7 @@ public void run () { } } } - toClose = new LinkedList(); + toClose = new ArrayList<>(); synchronized (rspConnections) { if (MAX_RSP_TIME != -1) { for (HttpConnection c : rspConnections) {