Skip to content

Commit 2fbd540

Browse files
committed
Merge branch '6.2.x'
# Conflicts: # spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java # spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java
2 parents ca7ebd6 + 403362f commit 2fbd540

File tree

8 files changed

+50
-13
lines changed

8 files changed

+50
-13
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/aot/InstanceSupplierCodeGenerator.java

+1
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ private void registerProxyIfNecessary(RuntimeHints runtimeHints, DependencyDescr
440440
}
441441
}
442442

443+
443444
record ConstructorDescriptor(String beanName, Constructor<?> constructor, Class<?> publicType) {
444445

445446
Class<?> actualType() {

Diff for: spring-core/src/main/java/org/springframework/util/StringUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,9 @@ else if (TOP_PATH.equals(element)) {
784784
pathElements.addFirst(CURRENT_PATH);
785785
}
786786

787-
final String joined = collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
788-
// avoid string concatenation with empty prefix
789-
return prefix.isEmpty() ? joined : prefix + joined;
787+
String joined = collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
788+
// Avoid String concatenation with empty prefix
789+
return (prefix.isEmpty() ? joined : prefix + joined);
790790
}
791791

792792
/**

Diff for: spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ List<T> get() {
461461
}
462462
}
463463

464-
public interface InterfaceWithDefaultMethod<T extends InheritsDefaultMethod.AbstractType> {
464+
public interface InterfaceWithDefaultMethod<T extends InterfaceWithDefaultMethod.AbstractType> {
465465

466466
default String get(T input) {
467467
throw new UnsupportedOperationException();

Diff for: spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jspecify.annotations.Nullable;
2626

2727
import org.springframework.core.io.ClassPathResource;
28+
import org.springframework.core.io.FileSystemResource;
2829
import org.springframework.core.io.Resource;
2930
import org.springframework.core.io.UrlResource;
3031
import org.springframework.core.log.LogFormatUtils;
@@ -60,12 +61,15 @@ public static void assertResourceLocation(@Nullable Resource location) {
6061
if (location instanceof org.springframework.core.io.PathResource) {
6162
return;
6263
}
63-
else if (location instanceof UrlResource) {
64-
path = location.getURL().toExternalForm();
64+
else if (location instanceof FileSystemResource fileSystemResource) {
65+
path = fileSystemResource.getPath();
6566
}
6667
else if (location instanceof ClassPathResource classPathResource) {
6768
path = classPathResource.getPath();
6869
}
70+
else if (location instanceof UrlResource) {
71+
path = location.getURL().toExternalForm();
72+
}
6973
else {
7074
path = location.getURL().getPath();
7175
}

Diff for: spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -26,6 +26,7 @@
2626
import reactor.test.StepVerifier;
2727

2828
import org.springframework.core.io.ClassPathResource;
29+
import org.springframework.core.io.FileSystemResource;
2930
import org.springframework.core.io.Resource;
3031
import org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest;
3132
import org.springframework.web.testfixture.server.MockServerWebExchange;
@@ -39,8 +40,7 @@ class PathResourceLookupFunctionTests {
3940
void normal() throws Exception {
4041
ClassPathResource location = new ClassPathResource("org/springframework/web/reactive/function/server/");
4142

42-
PathResourceLookupFunction
43-
function = new PathResourceLookupFunction("/resources/**", location);
43+
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
4444
MockServerHttpRequest mockRequest = MockServerHttpRequest.get("https://localhost/resources/response.txt").build();
4545
ServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), Collections.emptyList());
4646
Mono<Resource> result = function.apply(request);
@@ -124,4 +124,17 @@ void composeResourceLookupFunction() {
124124
.verify();
125125
}
126126

127+
@Test
128+
@SuppressWarnings("removal")
129+
void withPathResource() {
130+
org.springframework.core.io.PathResource location = new org.springframework.core.io.PathResource("/static/");
131+
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
132+
}
133+
134+
@Test
135+
void withFileSystemResource() {
136+
FileSystemResource location = new FileSystemResource("/static/");
137+
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
138+
}
139+
127140
}

Diff for: spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jspecify.annotations.Nullable;
2626

2727
import org.springframework.core.io.ClassPathResource;
28+
import org.springframework.core.io.FileSystemResource;
2829
import org.springframework.core.io.Resource;
2930
import org.springframework.core.io.UrlResource;
3031
import org.springframework.core.log.LogFormatUtils;
@@ -61,12 +62,15 @@ public static void assertResourceLocation(@Nullable Resource location) {
6162
if (location instanceof org.springframework.core.io.PathResource) {
6263
return;
6364
}
64-
else if (location instanceof UrlResource) {
65-
path = location.getURL().toExternalForm();
65+
else if (location instanceof FileSystemResource fileSystemResource) {
66+
path = fileSystemResource.getPath();
6667
}
6768
else if (location instanceof ClassPathResource classPathResource) {
6869
path = classPathResource.getPath();
6970
}
71+
else if (location instanceof UrlResource) {
72+
path = location.getURL().toExternalForm();
73+
}
7074
else {
7175
path = location.getURL().getPath();
7276
}

Diff for: spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java

+15-1
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-2025 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.
@@ -24,6 +24,7 @@
2424
import org.junit.jupiter.api.Test;
2525

2626
import org.springframework.core.io.ClassPathResource;
27+
import org.springframework.core.io.FileSystemResource;
2728
import org.springframework.core.io.Resource;
2829
import org.springframework.web.servlet.handler.PathPatternsTestUtils;
2930

@@ -102,4 +103,17 @@ private ServerRequest initRequest(String httpMethod, String requestUri) {
102103
Collections.emptyList());
103104
}
104105

106+
@Test
107+
@SuppressWarnings("removal")
108+
void withPathResource() {
109+
org.springframework.core.io.PathResource location = new org.springframework.core.io.PathResource("/static/");
110+
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
111+
}
112+
113+
@Test
114+
void withFileSystemResource() {
115+
FileSystemResource location = new FileSystemResource("/static/");
116+
PathResourceLookupFunction function = new PathResourceLookupFunction("/resources/**", location);
117+
}
118+
105119
}

Diff for: spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -56,6 +56,7 @@ class ResourceHandlerFunctionTests {
5656

5757
private ResourceHttpMessageConverter messageConverter;
5858

59+
5960
@BeforeEach
6061
void createContext() {
6162
this.messageConverter = new ResourceHttpMessageConverter();

0 commit comments

Comments
 (0)