Skip to content

Commit

Permalink
8303216: Prefer ArrayList to LinkedList in sun.net.httpserver.ServerImpl
Browse files Browse the repository at this point in the history
Reviewed-by: jpai, vtewari, stsypanov, dfuchs
  • Loading branch information
Andrey Turbanov committed Feb 28, 2023
1 parent a10d5ac commit 8815175
Showing 1 changed file with 7 additions and 8 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -164,7 +164,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<Event>();
events = new ArrayList<>();
logger.log (Level.DEBUG, "HttpServer created "+protocol+" "+ addr);
}

Expand Down Expand Up @@ -431,8 +431,7 @@ private void handleEvent (Event r) {
}
}

final LinkedList<HttpConnection> connsToRegister =
new LinkedList<HttpConnection>();
final ArrayList<HttpConnection> connsToRegister = new ArrayList<>();

void reRegister (HttpConnection c) {
/* re-register with selector */
Expand All @@ -457,7 +456,7 @@ public void run() {
synchronized (lolock) {
if (events.size() > 0) {
list = events;
events = new LinkedList<Event>();
events = new ArrayList<>();
}
}

Expand Down Expand Up @@ -1017,7 +1016,7 @@ void responseCompleted (HttpConnection c) {
*/
class IdleTimeoutTask extends TimerTask {
public void run () {
LinkedList<HttpConnection> toClose = new LinkedList<HttpConnection>();
ArrayList<HttpConnection> toClose = new ArrayList<>();
final long currentTime = System.currentTimeMillis();
synchronized (idleConnections) {
final Iterator<HttpConnection> it = idleConnections.iterator();
Expand Down Expand Up @@ -1058,7 +1057,7 @@ class ReqRspTimeoutTask extends TimerTask {

// runs every TIMER_MILLIS
public void run () {
LinkedList<HttpConnection> toClose = new LinkedList<HttpConnection>();
ArrayList<HttpConnection> toClose = new ArrayList<>();
final long currentTime = System.currentTimeMillis();
synchronized (reqConnections) {
if (MAX_REQ_TIME != -1) {
Expand All @@ -1075,7 +1074,7 @@ public void run () {
}
}
}
toClose = new LinkedList<HttpConnection>();
toClose = new ArrayList<>();
synchronized (rspConnections) {
if (MAX_RSP_TIME != -1) {
for (HttpConnection c : rspConnections) {
Expand Down

1 comment on commit 8815175

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.