Remove APIs marked for removal

See gh-30604
This commit is contained in:
Arjen Poutsma
2023-06-07 10:20:27 +02:00
parent 7f6f47b97b
commit df7223f39c
6 changed files with 11 additions and 720 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,8 +66,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
private int maxParts = -1;
private boolean streaming;
private Scheduler blockingOperationScheduler = Schedulers.boundedElastic();
private FileStorage fileStorage = FileStorage.tempDirectory(this::getBlockingOperationScheduler);
@@ -99,8 +97,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
* <li>non-file parts are rejected with {@link DataBufferLimitException}.
* </ul>
* <p>By default this is set to 256K.
* <p>Note that this property is ignored when
* {@linkplain #setStreaming(boolean) streaming} is enabled.
* @param maxInMemorySize the in-memory limit in bytes; if set to -1 the entire
* contents will be stored in memory
*/
@@ -112,7 +108,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
* Configure the maximum amount of disk space allowed for file parts.
* <p>By default this is set to -1, meaning that there is no maximum.
* <p>Note that this property is ignored when
* {@linkplain #setStreaming(boolean) streaming} is enabled, or when
* {@link #setMaxInMemorySize(int) maxInMemorySize} is set to -1.
*/
public void setMaxDiskUsagePerPart(long maxDiskUsagePerPart) {
@@ -133,7 +128,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
* named {@code spring-webflux-multipart} is created under the system
* temporary directory.
* <p>Note that this property is ignored when
* {@linkplain #setStreaming(boolean) streaming} is enabled, or when
* {@link #setMaxInMemorySize(int) maxInMemorySize} is set to -1.
* @throws IOException if an I/O error occurs, or the parent directory
* does not exist
@@ -149,7 +143,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
* {@link Schedulers#boundedElastic()} is used, but this property allows for
* changing it to an externally managed scheduler.
* <p>Note that this property is ignored when
* {@linkplain #setStreaming(boolean) streaming} is enabled, or when
* {@link #setMaxInMemorySize(int) maxInMemorySize} is set to -1.
* @see Schedulers#newBoundedElastic
*/
@@ -162,30 +155,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
return this.blockingOperationScheduler;
}
/**
* When set to {@code true}, the {@linkplain Part#content() part content}
* is streamed directly from the parsed input buffer stream, and not stored
* in memory nor file.
* When {@code false}, parts are backed by
* in-memory and/or file storage. Defaults to {@code false}.
* <p><strong>NOTE</strong> that with streaming enabled, the
* {@code Flux<Part>} that is produced by this message reader must be
* consumed in the original order, i.e. the order of the HTTP message.
* Additionally, the {@linkplain Part#content() body contents} must either
* be completely consumed or canceled before moving to the next part.
* <p>Also note that enabling this property effectively ignores
* {@link #setMaxInMemorySize(int) maxInMemorySize},
* {@link #setMaxDiskUsagePerPart(long) maxDiskUsagePerPart},
* {@link #setFileStorageDirectory(Path) fileStorageDirectory}, and
* {@link #setBlockingOperationScheduler(Scheduler) fileCreationScheduler}.
* @deprecated as of 6.0, in favor of {@link PartEvent} and
* {@link PartEventHttpMessageReader}
*/
@Deprecated(since = "6.0", forRemoval = true)
public void setStreaming(boolean streaming) {
this.streaming = streaming;
}
/**
* Set the character set used to decode headers.
* Defaults to UTF-8 as per RFC 7578.
@@ -236,7 +205,7 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
}
else {
return PartGenerator.createPart(partsTokens,
this.maxInMemorySize, this.maxDiskUsagePerPart, this.streaming,
this.maxInMemorySize, this.maxDiskUsagePerPart,
this.fileStorage.directory(), this.blockingOperationScheduler);
}
});

View File

@@ -38,7 +38,6 @@ import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Subscription;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
import reactor.core.scheduler.Scheduler;
@@ -68,8 +67,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
private final MonoSink<Part> sink;
private final boolean streaming;
private final int maxInMemorySize;
private final long maxDiskUsagePerPart;
@@ -80,12 +77,11 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
private PartGenerator(MonoSink<Part> sink, int maxInMemorySize, long maxDiskUsagePerPart,
boolean streaming, Mono<Path> fileStorageDirectory, Scheduler blockingOperationScheduler) {
Mono<Path> fileStorageDirectory, Scheduler blockingOperationScheduler) {
this.sink = sink;
this.maxInMemorySize = maxInMemorySize;
this.maxDiskUsagePerPart = maxDiskUsagePerPart;
this.streaming = streaming;
this.fileStorageDirectory = fileStorageDirectory;
this.blockingOperationScheduler = blockingOperationScheduler;
}
@@ -94,11 +90,10 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
* Creates parts from a given stream of tokens.
*/
public static Mono<Part> createPart(Flux<MultipartParser.Token> tokens, int maxInMemorySize,
long maxDiskUsagePerPart, boolean streaming, Mono<Path> fileStorageDirectory,
Scheduler blockingOperationScheduler) {
long maxDiskUsagePerPart, Mono<Path> fileStorageDirectory, Scheduler blockingOperationScheduler) {
return Mono.create(sink -> {
PartGenerator generator = new PartGenerator(sink, maxInMemorySize, maxDiskUsagePerPart, streaming,
PartGenerator generator = new PartGenerator(sink, maxInMemorySize, maxDiskUsagePerPart,
fileStorageDirectory, blockingOperationScheduler);
sink.onCancel(generator);
@@ -134,20 +129,10 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
changeState(currentState, new FormFieldState(headers));
requestToken();
}
else if (!this.streaming) {
else {
changeState(currentState, new InMemoryState(headers));
requestToken();
}
else {
Flux<DataBuffer> streamingContent = Flux.create(contentSink -> {
State newState = new StreamingState(contentSink);
if (changeState(currentState, newState)) {
contentSink.onRequest(l -> requestToken());
requestToken();
}
});
emitPart(DefaultParts.part(headers, streamingContent));
}
}
@Override
@@ -225,8 +210,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
* <ol>
* <li>If the part is a {@linkplain MultipartUtils#isFormField(HttpHeaders) form field},
* the creator will be in the {@link FormFieldState}.</li>
* <li>If {@linkplain #streaming} is enabled, the creator will be in the
* {@link StreamingState}.</li>
* <li>Otherwise, the creator will initially be in the
* {@link InMemoryState}, but will switch over to {@link CreateFileState}
* when the part byte count exceeds {@link #maxInMemorySize},
@@ -352,61 +335,11 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
/**
* The creator state when {@link #streaming} is {@code true} (and not
* handling a form field). Relays all received buffers to a sink.
*/
private final class StreamingState implements State {
private final FluxSink<DataBuffer> bodySink;
public StreamingState(FluxSink<DataBuffer> bodySink) {
this.bodySink = bodySink;
}
@Override
public void body(DataBuffer dataBuffer) {
if (!this.bodySink.isCancelled()) {
this.bodySink.next(dataBuffer);
if (this.bodySink.requestedFromDownstream() > 0) {
requestToken();
}
}
else {
DataBufferUtils.release(dataBuffer);
// even though the body sink is canceled, the (outer) part sink
// might not be, so request another token
requestToken();
}
}
@Override
public void onComplete() {
if (!this.bodySink.isCancelled()) {
this.bodySink.complete();
}
}
@Override
public void error(Throwable throwable) {
if (!this.bodySink.isCancelled()) {
this.bodySink.error(throwable);
}
}
@Override
public String toString() {
return "STREAMING";
}
}
/**
* The creator state when {@link #streaming} is {@code false} (and not
* handling a form field). Stores all received buffers in a queue.
* The creator state when not handling a form field.
* Stores all received buffers in a queue.
* If the byte count exceeds {@link #maxInMemorySize}, the creator state
* is changed to {@link CreateFileState}, and eventually to
* {@link CreateFileState}.
* {@link WritingFileState}.
*/
private final class InMemoryState implements State {

View File

@@ -51,8 +51,6 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
private final HttpHeaders headers;
// TODO: remove @Nullable once deprecated constructors have been removed
@Nullable
private final HttpMethod method;
@Nullable
@@ -71,22 +69,6 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
private String logPrefix;
/**
* Constructor with the URI and headers for the request.
* @param uri the URI for the request
* @param contextPath the context path for the request
* @param headers the headers for the request (as {@link MultiValueMap})
* @since 5.3
* @deprecated since 6.0.8, in favor of {@link #AbstractServerHttpRequest(HttpMethod, URI, String, MultiValueMap)}
*/
@Deprecated(since = "6.0.8", forRemoval = true)
public AbstractServerHttpRequest(URI uri, @Nullable String contextPath, MultiValueMap<String, String> headers) {
this.uri = uri;
this.path = RequestPath.parse(uri, contextPath);
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
this.method = null;
}
/**
* Constructor with the method, URI and headers for the request.
* @param method the HTTP method for the request
@@ -108,21 +90,6 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
}
/**
* Constructor with the URI and headers for the request.
* @param uri the URI for the request
* @param contextPath the context path for the request
* @param headers the headers for the request (as {@link HttpHeaders})
* @deprecated since 6.0.8, in favor of {@link #AbstractServerHttpRequest(HttpMethod, URI, String, MultiValueMap)}
*/
@Deprecated(since = "6.0.8", forRemoval = true)
public AbstractServerHttpRequest(URI uri, @Nullable String contextPath, HttpHeaders headers) {
this.uri = uri;
this.path = RequestPath.parse(uri, contextPath);
this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
this.method = null;
}
@Override
public String getId() {
@@ -147,14 +114,7 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
@Override
public HttpMethod getMethod() {
// TODO: remove null check once deprecated constructors have been removed
if (this.method != null) {
return this.method;
}
else {
throw new IllegalStateException("No HttpMethod provided in constructor, " +
"and AbstractServerHttpRequest::getMethod not overridden");
}
return this.method;
}
@Override