diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java index 4e1bc3068b6..eecf24215a5 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/DefaultPartHttpMessageReader.java @@ -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 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 } private Scheduler getBlockingOperationScheduler() { - return this.blockingOperationScheduler; + return (this.blockingOperationScheduler != null ? + this.blockingOperationScheduler : Schedulers.boundedElastic()); } /** @@ -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()); } }); });