Top Description Inners Fields Constructors Methods
jdk.internal.net.http

pack-priv Class MultiExchange<T>

extends Object
implements Cancelable
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.common.Cancelable
Imports
java.io.IOException, java.lang.ref.WeakReference, java.net.ConnectException, java.net.http.HttpConnectTimeoutException, .HttpClient, .HttpHeaders, .HttpRequest, .HttpResponse, .HttpResponse.BodySubscriber, .HttpResponse.PushPromiseHandler, .HttpTimeoutException, java.time.Duration, java.security.AccessControlContext, java.util.List, .ListIterator, .Objects, .Optional, java.util.concurrent.CancellationException, .CompletableFuture, .CompletionStage, .CompletionException, .ExecutionException, .Executor, .Flow, java.util.concurrent.atomic.AtomicInteger, .AtomicLong, .AtomicReference, java.util.function.Function, jdk.internal.net.http.common.Cancelable, .Log, .Logger, .MinimalFuture, .ConnectionExpiredException, .Utils

Encapsulates multiple Exchanges belonging to one HttpRequestImpl. - manages filters - retries due to filters. - I/O errors and most other exceptions get returned directly to user Creates a new Exchange for each request/response interaction

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final AccessControlContext
acc

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
pack-priv final AtomicInteger
pack-priv volatile boolean
pack-priv final HttpClientImpl
private final MultiExchange.ConnectTimeoutTracker
pack-priv HttpRequestImpl
pack-priv static final Logger
pack-priv static final int
pack-priv Exchange<T>
pack-priv final HttpClientImpl.DelegatingExecutor
pack-priv volatile boolean
private final List<HeaderFilter>
pack-priv AtomicReference<CancellationException>
pack-priv static final int
pack-priv volatile int
pack-priv Exchange<T>
pack-priv HttpRequestImpl
pack-priv volatile AuthenticationFilter.AuthInfo
proxyauth

Filter fields.

pack-priv final PushGroup<T>
private final HttpRequestImpl
pack-priv volatile HttpResponse<T>
pack-priv final HttpResponse.BodyHandler<T>
pack-priv volatile ResponseTimerEvent
private static final boolean
RETRY_ALWAYS

True if ALL ( even non-idempotent ) requests can be automatic retried.

pack-priv static final boolean
RETRY_CONNECT

True if ConnectException should cause a retry.

pack-priv volatile Throwable
pack-priv volatile AuthenticationFilter.AuthInfo
serverauth

Filter fields.

private final HttpRequest

Constructor Summary

AccessConstructor and Description
pack-priv
MultiExchange(HttpRequest userRequest, HttpRequestImpl requestImpl, HttpClientImpl client, HttpResponse.BodyHandler<T> responseHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler, AccessControlContext acc)
References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

MultiExchange with one final response.

Method Summary

Modifier and TypeMethod and Description
private boolean
private static boolean
public void
public boolean

Returns:

true if the exchange was cancelled, false otherwise.
cancel
(boolean
if true, and this exchange is not already cancelled, this method will attempt to interrupt and cancel the exchange. Otherwise, the exchange is allowed to proceed and this method does nothing.
mayInterruptIfRunning
)

Implements jdk.internal.net.http.common.Cancelable.cancel.

Used to relay a call from CompletableFuture#cancel(boolean) to this multi exchange for the purpose of cancelling the HTTP exchange.

private void
private static boolean
canRetryRequest(HttpRequest request)

Returns true if the given request can be automatically retried.

pack-priv HttpClientImpl
private static boolean
private CompletableFuture<Response>
getExceptionalCF(Throwable t)

Takes a Throwable and returns a suitable CompletableFuture that is completed exceptionally, or null.

pack-priv synchronized Exchange<T>
private CompletableFuture<HttpResponse<T>>
private static boolean
isIdempotentRequest(HttpRequest request)

Returns true is given request has an idempotent method.

public <U> MinimalFuture<U>
public Optional<Duration>
pack-priv boolean
private void
public CompletableFuture<HttpResponse<T>>
private CompletableFuture<HttpResponse<T>>
private CompletableFuture<Response>
private HttpRequestImpl
private Throwable
private boolean
private static boolean
private void
setExchange(Exchange<T> exchange)

private HttpTimeoutException
pack-priv HttpClient.Version
private CompletableFuture<HttpResponse<T>>
private Throwable
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accback to summary
pack-priv final AccessControlContext acc

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:removal
attemptsback to summary
pack-priv final AtomicInteger attempts
cancelledback to summary
pack-priv volatile boolean cancelled
clientback to summary
pack-priv final HttpClientImpl client
connectTimeoutback to summary
private final MultiExchange.ConnectTimeoutTracker connectTimeout
currentreqback to summary
pack-priv HttpRequestImpl currentreq
debugback to summary
pack-priv static final Logger debug
DEFAULT_MAX_ATTEMPTSback to summary
pack-priv static final int DEFAULT_MAX_ATTEMPTS
exchangeback to summary
pack-priv Exchange<T> exchange
executorback to summary
pack-priv final HttpClientImpl.DelegatingExecutor executor
expiredOnceback to summary
pack-priv volatile boolean expiredOnce
filtersback to summary
private final List<HeaderFilter> filters
interruptedback to summary
pack-priv AtomicReference<CancellationException> interrupted
max_attemptsback to summary
pack-priv static final int max_attempts
numberOfRedirectsback to summary
pack-priv volatile int numberOfRedirects
previousback to summary
pack-priv Exchange<T> previous
previousreqback to summary
pack-priv HttpRequestImpl previousreq
proxyauthback to summary
pack-priv volatile AuthenticationFilter.AuthInfo proxyauth

Filter fields. These are attached as required by filters and only used by the filter implementations. This could be generalised into Objects that are passed explicitly to the filters (one per MultiExchange object, and one per Exchange object possibly)

pushGroupback to summary
pack-priv final PushGroup<T> pushGroup
requestback to summary
private final HttpRequestImpl request
responseback to summary
pack-priv volatile HttpResponse<T> response
responseHandlerback to summary
pack-priv final HttpResponse.BodyHandler<T> responseHandler
responseTimerEventback to summary
pack-priv volatile ResponseTimerEvent responseTimerEvent
RETRY_ALWAYSback to summary
private static final boolean RETRY_ALWAYS

True if ALL ( even non-idempotent ) requests can be automatic retried.

RETRY_CONNECTback to summary
pack-priv static final boolean RETRY_CONNECT

True if ConnectException should cause a retry. Enabled by default

retryCauseback to summary
pack-priv volatile Throwable retryCause
serverauthback to summary
pack-priv volatile AuthenticationFilter.AuthInfo serverauth

Filter fields. These are attached as required by filters and only used by the filter implementations. This could be generalised into Objects that are passed explicitly to the filters (one per MultiExchange object, and one per Exchange object possibly)

userRequestback to summary
private final HttpRequest userRequest

Constructor Detail

MultiExchangeback to summary
pack-priv MultiExchange(HttpRequest userRequest, HttpRequestImpl requestImpl, HttpClientImpl client, HttpResponse.BodyHandler<T> responseHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler, AccessControlContext acc)

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

MultiExchange with one final response.

Method Detail

bodyIsPresentback to summary
private boolean bodyIsPresent(Response r)
bodyNotPermittedback to summary
private static boolean bodyNotPermitted(Response r)
cancelback to summary
public void cancel(IOException cause)
cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements jdk.internal.net.http.common.Cancelable.cancel.

Used to relay a call from CompletableFuture#cancel(boolean) to this multi exchange for the purpose of cancelling the HTTP exchange.

Parameters
mayInterruptIfRunning:boolean

if true, and this exchange is not already cancelled, this method will attempt to interrupt and cancel the exchange. Otherwise, the exchange is allowed to proceed and this method does nothing.

Returns:boolean

true if the exchange was cancelled, false otherwise.

Annotations
@Override
cancelTimerback to summary
private void cancelTimer()
canRetryRequestback to summary
private static boolean canRetryRequest(HttpRequest request)

Returns true if the given request can be automatically retried.

clientback to summary
pack-priv HttpClientImpl client()
disableRetryConnectback to summary
private static boolean disableRetryConnect()
getExceptionalCFback to summary
private CompletableFuture<Response> getExceptionalCF(Throwable t)

Takes a Throwable and returns a suitable CompletableFuture that is completed exceptionally, or null.

getExchangeback to summary
pack-priv synchronized Exchange<T> getExchange()
handleNoBodyback to summary
private CompletableFuture<HttpResponse<T>> handleNoBody(Response r, Exchange<T> exch)
isIdempotentRequestback to summary
private static boolean isIdempotentRequest(HttpRequest request)

Returns true is given request has an idempotent method.

newMinimalFutureback to summary
public <U> MinimalFuture<U> newMinimalFuture()
remainingConnectTimeoutback to summary
public Optional<Duration> remainingConnectTimeout()
requestCancelledback to summary
pack-priv boolean requestCancelled()
requestFiltersback to summary
private void requestFilters(HttpRequestImpl r) throws IOException
responseAsyncback to summary
public CompletableFuture<HttpResponse<T>> responseAsync(Executor executor)
responseAsync0back to summary
private CompletableFuture<HttpResponse<T>> responseAsync0(CompletableFuture<Void> start)
responseAsyncImplback to summary
private CompletableFuture<Response> responseAsyncImpl()
responseFiltersback to summary
private HttpRequestImpl responseFilters(Response response) throws IOException
retryCauseback to summary
private Throwable retryCause(Throwable t)
retryOnFailureback to summary
private boolean retryOnFailure(Throwable t)
retryPostValueback to summary
private static boolean retryPostValue()
setExchangeback to summary
private void setExchange(Exchange<T> exchange)
toTimeoutExceptionback to summary
private HttpTimeoutException toTimeoutException(IOException ioe)
versionback to summary
pack-priv HttpClient.Version version()
whenCancelledback to summary
private CompletableFuture<HttpResponse<T>> whenCancelled(Throwable t)
wrapIfCancelledback to summary
private Throwable wrapIfCancelled(Throwable cause)
jdk.internal.net.http back to summary

pack-priv final Class MultiExchange.CancelableRef

extends Object
implements Cancelable
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.common.Cancelable

Field Summary

Modifier and TypeField and Description
private final WeakReference<Cancelable>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(boolean
true if an attempt to stop the task should be made even if the task has already started; otherwise, in-progress tasks are allowed to complete.
mayInterruptIfRunning
)

Implements jdk.internal.net.http.common.Cancelable.cancel.

Attempts to cancel execution of a task.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelableRefback to summary
private final WeakReference<Cancelable> cancelableRef

Constructor Detail

CancelableRefback to summary
pack-priv CancelableRef(Cancelable cancelable)

Method Detail

cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements jdk.internal.net.http.common.Cancelable.cancel.

Doc from jdk.internal.net.http.common.Cancelable.cancel.

Attempts to cancel execution of a task. This attempt may not succeed if the task has already completed, has already been cancelled, or could not be cancelled for some other reason.

Parameters
mayInterruptIfRunning:boolean

true if an attempt to stop the task should be made even if the task has already started; otherwise, in-progress tasks are allowed to complete.

Returns:boolean

false if the task could not be cancelled, typically because it has already completed normally; true otherwise

Annotations
@Override
jdk.internal.net.http back to summary

private final Class MultiExchange.ConnectTimeoutTracker

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Duration
pack-priv final AtomicLong

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Duration
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxback to summary
pack-priv final Duration max
startTimeback to summary
pack-priv final AtomicLong startTime

Constructor Detail

ConnectTimeoutTrackerback to summary
pack-priv ConnectTimeoutTracker(Duration connectTimeout)

Method Detail

getRemainingback to summary
pack-priv Duration getRemaining()
resetback to summary
pack-priv void reset()
jdk.internal.net.http back to summary

pack-priv Class MultiExchange.NullSubscription

extends Object
implements Subscription
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Flow.Subscription

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Implements java.util.concurrent.Flow.Subscription.cancel.

Causes the Subscriber to (eventually) stop receiving messages.

public void
request(long
the increment of demand; a value of Long.MAX_VALUE may be considered as effectively unbounded
n
)

Implements java.util.concurrent.Flow.Subscription.request.

Adds the given number n of items to the current unfulfilled demand for this subscription.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NullSubscriptionback to summary
pack-priv NullSubscription()

Method Detail

cancelback to summary
public void cancel()

Implements java.util.concurrent.Flow.Subscription.cancel.

Doc from java.util.concurrent.Flow.Subscription.cancel.

Causes the Subscriber to (eventually) stop receiving messages. Implementation is best-effort -- additional messages may be received after invoking this method. A cancelled subscription need not ever receive an onComplete or onError signal.

Annotations
@Override
requestback to summary
public void request(long n)

Implements java.util.concurrent.Flow.Subscription.request.

Doc from java.util.concurrent.Flow.Subscription.request.

Adds the given number n of items to the current unfulfilled demand for this subscription. If n is less than or equal to zero, the Subscriber will receive an onError signal with an IllegalArgumentException argument. Otherwise, the Subscriber will receive up to n additional onNext invocations (or fewer if terminated).

Parameters
n:long

the increment of demand; a value of Long.MAX_VALUE may be considered as effectively unbounded

Annotations
@Override