Skip to content

Commit 39c0400

Browse files
committed
Lazy use of Reactor Scheduler in DefaultPartHttpMessageReader
Closes gh-33218
1 parent 50906e7 commit 39c0400

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,7 +66,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
6666

6767
private int maxParts = -1;
6868

69-
private Scheduler blockingOperationScheduler = Schedulers.boundedElastic();
69+
@Nullable
70+
private Scheduler blockingOperationScheduler;
7071

7172
private FileStorage fileStorage = FileStorage.tempDirectory(this::getBlockingOperationScheduler);
7273

@@ -152,7 +153,8 @@ public void setBlockingOperationScheduler(Scheduler blockingOperationScheduler)
152153
}
153154

154155
private Scheduler getBlockingOperationScheduler() {
155-
return this.blockingOperationScheduler;
156+
return (this.blockingOperationScheduler != null ?
157+
this.blockingOperationScheduler : Schedulers.boundedElastic());
156158
}
157159

158160
/**
@@ -206,7 +208,7 @@ public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage mess
206208
else {
207209
return PartGenerator.createPart(partsTokens,
208210
this.maxInMemorySize, this.maxDiskUsagePerPart,
209-
this.fileStorage.directory(), this.blockingOperationScheduler);
211+
this.fileStorage.directory(), getBlockingOperationScheduler());
210212
}
211213
});
212214
});

0 commit comments

Comments
 (0)