Skip to content

Commit 018560f

Browse files
committed
Merge branch '4.1.x' into 4.2.x
2 parents 79c78f0 + 8055889 commit 018560f

File tree

4 files changed

+122
-5
lines changed

4 files changed

+122
-5
lines changed

docs/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"dependencies": {
3-
"antora": "3.2.0-alpha.4",
3+
"antora": "3.2.0-alpha.8",
44
"@antora/atlas-extension": "1.0.0-alpha.2",
5-
"@antora/collector-extension": "1.0.0-alpha.3",
5+
"@antora/collector-extension": "1.0.1",
66
"@asciidoctor/tabs": "1.0.0-beta.6",
7-
"@springio/antora-extensions": "1.11.1",
8-
"@springio/asciidoctor-extensions": "1.0.0-alpha.10"
7+
"@springio/antora-extensions": "1.14.2",
8+
"@springio/asciidoctor-extensions": "1.0.0-alpha.14"
99
}
1010
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.springframework.cloud.gateway.server.mvc.common;
19+
20+
import java.util.Map;
21+
22+
import org.springframework.boot.SpringApplication;
23+
import org.springframework.boot.env.EnvironmentPostProcessor;
24+
import org.springframework.core.env.ConfigurableEnvironment;
25+
import org.springframework.core.env.MapPropertySource;
26+
import org.springframework.util.StringUtils;
27+
28+
public class MultipartEnvironmentPostProcessor implements EnvironmentPostProcessor {
29+
30+
/* for testing */ static final String MULTIPART_ENABLED_PROPERTY = "spring.servlet.multipart.enabled";
31+
/* for testing */ static final String MULTIPART_PROPERTY_SOURCE_NAME = "gatewayServerWebmvcMultipartPropertySource";
32+
33+
@Override
34+
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
35+
String multipartEnabled = environment.getProperty(MULTIPART_ENABLED_PROPERTY);
36+
if (!StringUtils.hasText(multipartEnabled)) {
37+
// no user set property, set it to false.
38+
MapPropertySource propertySource = new MapPropertySource(MULTIPART_PROPERTY_SOURCE_NAME,
39+
Map.of(MULTIPART_ENABLED_PROPERTY, Boolean.FALSE));
40+
environment.getPropertySources().addFirst(propertySource);
41+
}
42+
}
43+
44+
}

spring-cloud-gateway-server-mvc/src/main/resources/META-INF/spring.factories

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
#
2+
# Copyright 2025 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
#
17+
118
org.springframework.cloud.gateway.server.mvc.filter.FilterSupplier=\
219
org.springframework.cloud.gateway.server.mvc.filter.Bucket4jFilterFunctions.FilterSupplier,\
320
org.springframework.cloud.gateway.server.mvc.filter.CircuitBreakerFilterFunctions.FilterSupplier,\
@@ -14,4 +31,5 @@ org.springframework.cloud.gateway.server.mvc.predicate.PredicateSupplier=\
1431
org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates.PredicateSupplier
1532

1633
org.springframework.boot.env.EnvironmentPostProcessor=\
17-
org.springframework.cloud.gateway.server.mvc.GatewayServerMvcAutoConfiguration.GatewayHttpClientEnvironmentPostProcessor
34+
org.springframework.cloud.gateway.server.mvc.GatewayServerMvcAutoConfiguration.GatewayHttpClientEnvironmentPostProcessor,\
35+
org.springframework.cloud.gateway.server.mvc.common.MultipartEnvironmentPostProcessor
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2013-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
19+
package org.springframework.cloud.gateway.server.mvc.common;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
import org.springframework.mock.env.MockEnvironment;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
import static org.springframework.cloud.gateway.server.mvc.common.MultipartEnvironmentPostProcessor.MULTIPART_ENABLED_PROPERTY;
27+
import static org.springframework.cloud.gateway.server.mvc.common.MultipartEnvironmentPostProcessor.MULTIPART_PROPERTY_SOURCE_NAME;
28+
29+
public class MultipartEnvironmentPostProcessorTests {
30+
31+
@Test
32+
void multipartDisabledByDefault() {
33+
MockEnvironment environment = new MockEnvironment();
34+
MultipartEnvironmentPostProcessor processor = new MultipartEnvironmentPostProcessor();
35+
processor.postProcessEnvironment(environment, null);
36+
37+
assertThat(environment.getPropertySources().contains(MULTIPART_PROPERTY_SOURCE_NAME)).isTrue();
38+
39+
Boolean multipartEnabled = environment.getProperty(MULTIPART_ENABLED_PROPERTY, Boolean.class);
40+
assertThat(multipartEnabled).isFalse();
41+
}
42+
43+
@Test
44+
void multipartEnabledByUser() {
45+
MockEnvironment environment = new MockEnvironment();
46+
environment.setProperty(MULTIPART_ENABLED_PROPERTY, "true");
47+
MultipartEnvironmentPostProcessor processor = new MultipartEnvironmentPostProcessor();
48+
processor.postProcessEnvironment(environment, null);
49+
50+
assertThat(environment.getPropertySources().contains(MULTIPART_PROPERTY_SOURCE_NAME)).isFalse();
51+
52+
Boolean multipartEnabled = environment.getProperty(MULTIPART_ENABLED_PROPERTY, Boolean.class);
53+
assertThat(multipartEnabled).isTrue();
54+
}
55+
}

0 commit comments

Comments
 (0)