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.
Original file line number Diff line number Diff line change
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

5 comments 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.

@MBaesken
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 8815175 Jul 12, 2024

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch backport-MBaesken-88151758-master in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 88151758 from the openjdk/jdk repository.

The commit being backported was authored by Andrey Turbanov on 28 Feb 2023 and was reviewed by Jaikiran Pai, Vyom Tewari, Sergey Tsypanov and Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-MBaesken-88151758-master:backport-MBaesken-88151758-master
$ git checkout backport-MBaesken-88151758-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-MBaesken-88151758-master

@MBaesken
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 8815175 Jul 18, 2024

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch backport-MBaesken-88151758-master in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 88151758 from the openjdk/jdk repository.

The commit being backported was authored by Andrey Turbanov on 28 Feb 2023 and was reviewed by Jaikiran Pai, Vyom Tewari, Sergey Tsypanov and Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git backport-MBaesken-88151758-master:backport-MBaesken-88151758-master
$ git checkout backport-MBaesken-88151758-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git backport-MBaesken-88151758-master

⚠️ @MBaesken You are not yet a collaborator in my fork openjdk-bots/jdk11u-dev. An invite will be sent out and you need to accept it before you can proceed.

Please sign in to comment.