Polishing

This commit is contained in:
Sam Brannen
2026-01-19 19:16:28 +01:00
parent 693ec8219f
commit 7917ae53e8
5 changed files with 13 additions and 27 deletions
@@ -75,7 +75,6 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
/**
* Configure the maximum amount of memory that is allowed per headers section of each part.
* When the limit
* @param byteCount the maximum amount of memory for headers
*/
public void setMaxHeadersSize(int byteCount) {
@@ -93,8 +92,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
* Configure the maximum amount of memory allowed per part.
* When the limit is exceeded:
* <ul>
* <li>file parts are written to a temporary file.
* <li>non-file parts are rejected with {@link DataBufferLimitException}.
* <li>File parts are written to a temporary file.
* <li>Non-file parts are rejected with {@link DataBufferLimitException}.
* </ul>
* <p>By default this is set to 256K.
* @param maxInMemorySize the in-memory limit in bytes; if set to -1 the entire
@@ -158,7 +157,7 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
/**
* Set the character set used to decode headers.
* Defaults to UTF-8 as per RFC 7578.
* <p>Defaults to UTF-8 as per RFC 7578.
* @param headersCharset the charset to use for decoding headers
* @since 5.3.6
* @see <a href="https://tools.ietf.org/html/rfc7578#section-5.1">RFC-7578 Section 5.1</a>
@@ -218,5 +217,4 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
return this.maxParts > 0 && count > this.maxParts;
}
}
@@ -52,7 +52,8 @@ import org.springframework.util.FastByteArrayOutputStream;
/**
* Subscribes to a token stream (i.e. the result of
* {@link MultipartParser#parse(Flux, byte[], int, Charset)}), and produces a flux of {@link Part} objects.
* {@link MultipartParser#parse(Flux, byte[], int, Charset)}), and produces a flux
* of {@link Part} objects.
*
* @author Arjen Poutsma
* @since 5.3
@@ -330,7 +331,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
public String toString() {
return "FORM-FIELD";
}
}
@@ -422,7 +422,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
public String toString() {
return "IN-MEMORY";
}
}
@@ -487,7 +486,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
this.releaseOnDispose = false;
if (changeState(this, newState)) {
newState.writeBuffers(this.content);
if (this.completed) {
@@ -512,10 +510,9 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
public String toString() {
return "CREATE-FILE";
}
}
private final class IdleFileState implements State {
private final HttpHeaders headers;
@@ -542,7 +539,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
public void body(DataBuffer dataBuffer) {
long count = this.byteCount.addAndGet(dataBuffer.readableByteCount());
if (PartGenerator.this.maxDiskUsagePerPart == -1 || count <= PartGenerator.this.maxDiskUsagePerPart) {
this.closeOnDispose = false;
this.deleteOnDispose = false;
WritingFileState newState = new WritingFileState(this);
@@ -582,16 +578,14 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
}
}
@Override
public String toString() {
return "IDLE-FILE";
}
}
private final class WritingFileState implements State {
private final class WritingFileState implements State {
private final HttpHeaders headers;
@@ -643,9 +637,7 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
Mono.just(dataBuffer)
.flatMap(this::writeInternal)
.subscribeOn(PartGenerator.this.blockingOperationScheduler)
.subscribe(null,
PartGenerator.this::emitError,
this::writeComplete);
.subscribe(null, PartGenerator.this::emitError, this::writeComplete);
}
public void writeBuffers(Iterable<DataBuffer> dataBuffers) {
@@ -653,9 +645,7 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
.concatMap(this::writeInternal)
.then()
.subscribeOn(PartGenerator.this.blockingOperationScheduler)
.subscribe(null,
PartGenerator.this::emitError,
this::writeComplete);
.subscribe(null, PartGenerator.this::emitError, this::writeComplete);
}
private void writeComplete() {
@@ -710,7 +700,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
this.disposed = true;
}
@Override
public String toString() {
return "WRITE-FILE";
@@ -738,7 +727,6 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
public String toString() {
return "DISPOSED";
}
}
}