Browse Source

Lazy use of Reactor Scheduler in DefaultPartHttpMessageReader

Closes gh-33218
pull/33222/head
rstoyanchev 2 years ago
parent
commit
39c040005e
  1. 10
      spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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,7 +66,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements @@ -66,7 +66,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
private int maxParts = -1;
private Scheduler blockingOperationScheduler = Schedulers.boundedElastic();
@Nullable
private Scheduler blockingOperationScheduler;
private FileStorage fileStorage = FileStorage.tempDirectory(this::getBlockingOperationScheduler);
@ -152,7 +153,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements @@ -152,7 +153,8 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
}
private Scheduler getBlockingOperationScheduler() {
return this.blockingOperationScheduler;
return (this.blockingOperationScheduler != null ?
this.blockingOperationScheduler : Schedulers.boundedElastic());
}
/**
@ -206,7 +208,7 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements @@ -206,7 +208,7 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
else {
return PartGenerator.createPart(partsTokens,
this.maxInMemorySize, this.maxDiskUsagePerPart,
this.fileStorage.directory(), this.blockingOperationScheduler);
this.fileStorage.directory(), getBlockingOperationScheduler());
}
});
});

Loading…
Cancel
Save