8253178: Replace LinkedList Impl in net.http.FilterFactory
Reviewed-by: dfuchs
This commit is contained in:
parent
94f5e441f6
commit
2309b7d8fc
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,20 +25,20 @@
|
||||
|
||||
package jdk.internal.net.http;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class FilterFactory {
|
||||
|
||||
// Strictly-ordered list of filters.
|
||||
final LinkedList<Class<? extends HeaderFilter>> filterClasses = new LinkedList<>();
|
||||
final List<Class<? extends HeaderFilter>> filterClasses = new ArrayList<>(3);
|
||||
|
||||
public void addFilter(Class<? extends HeaderFilter> type) {
|
||||
filterClasses.add(type);
|
||||
}
|
||||
|
||||
LinkedList<HeaderFilter> getFilterChain() {
|
||||
LinkedList<HeaderFilter> l = new LinkedList<>();
|
||||
List<HeaderFilter> getFilterChain() {
|
||||
List<HeaderFilter> l = new ArrayList<>(filterClasses.size());
|
||||
for (Class<? extends HeaderFilter> clazz : filterClasses) {
|
||||
try {
|
||||
// Requires a public no arg constructor.
|
||||
|
@ -56,14 +56,12 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -1206,7 +1204,7 @@ final class HttpClientImpl extends HttpClient implements Trackable {
|
||||
filters.addFilter(f);
|
||||
}
|
||||
|
||||
final LinkedList<HeaderFilter> filterChain() {
|
||||
final List<HeaderFilter> filterChain() {
|
||||
return filters.getFilterChain();
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.ConnectException;
|
||||
import java.net.http.HttpConnectTimeoutException;
|
||||
import java.time.Duration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.security.AccessControlContext;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CancellationException;
|
||||
@ -100,7 +100,7 @@ class MultiExchange<T> implements Cancelable {
|
||||
"jdk.httpclient.redirects.retrylimit", DEFAULT_MAX_ATTEMPTS
|
||||
);
|
||||
|
||||
private final LinkedList<HeaderFilter> filters;
|
||||
private final List<HeaderFilter> filters;
|
||||
ResponseTimerEvent responseTimerEvent;
|
||||
volatile boolean cancelled;
|
||||
AtomicReference<CancellationException> interrupted = new AtomicReference<>();
|
||||
@ -241,9 +241,9 @@ class MultiExchange<T> implements Cancelable {
|
||||
private HttpRequestImpl responseFilters(Response response) throws IOException
|
||||
{
|
||||
Log.logTrace("Applying response filters");
|
||||
Iterator<HeaderFilter> reverseItr = filters.descendingIterator();
|
||||
while (reverseItr.hasNext()) {
|
||||
HeaderFilter filter = reverseItr.next();
|
||||
ListIterator<HeaderFilter> reverseItr = filters.listIterator(filters.size());
|
||||
while (reverseItr.hasPrevious()) {
|
||||
HeaderFilter filter = reverseItr.previous();
|
||||
Log.logTrace("Applying {0}", filter);
|
||||
HttpRequestImpl newreq = filter.response(response);
|
||||
if (newreq != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user