Skip to content

Commit 0eefac2

Browse files
committed
Polishing contribution
Closes gh-35758
1 parent e99791f commit 0eefac2

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

framework-docs/modules/ROOT/pages/web/webflux/ann-rest-exceptions.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ Message codes and arguments for each error are also resolved via `MessageSource`
135135
| `+{0}+` the list of global errors, `+{1}+` the list of field errors.
136136
Message codes and arguments for each error are also resolved via `MessageSource`.
137137

138+
| `NoResourceFoundException`
139+
| (default)
140+
| `+{0}+` the request path (or portion of) used to find a resource
141+
138142
|===
139143

140144
NOTE: Unlike other exceptions, the message arguments for

framework-docs/modules/ROOT/pages/web/webmvc/mvc-ann-rest-exceptions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Message codes and arguments for each error are also resolved via `MessageSource`
171171

172172
| `NoResourceFoundException`
173173
| (default)
174-
| `+{0}+` the resource
174+
| `+{0}+` the request path (or portion of) used to find a resource
175175

176176
| `TypeMismatchException`
177177
| (default)

spring-webflux/src/main/java/org/springframework/web/reactive/resource/NoResourceFoundException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
@SuppressWarnings("serial")
3232
public class NoResourceFoundException extends ResponseStatusException {
3333

34-
3534
public NoResourceFoundException(URI uri, String resourcePath) {
36-
super(HttpStatus.NOT_FOUND, "No static resource " + resourcePath + " for request '" + uri + "'.");
35+
super(HttpStatus.NOT_FOUND,
36+
"No static resource " + resourcePath + " for request '" + uri + "'.",
37+
null, null, new Object[] { resourcePath});
38+
3739
setDetail("No static resource " + resourcePath + ".");
3840
}
3941

spring-webflux/src/test/java/org/springframework/web/reactive/resource/NoResourceFoundExceptionTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ void detailShouldContainResourcePath() {
4040
assertThat(noResourceFoundException.getBody().getDetail()).isEqualTo("No static resource /resource.");
4141
}
4242

43+
@Test
44+
void messageArgumentsShouldContainResourcePath() {
45+
var noResourceFoundException = new NoResourceFoundException(URI.create("/context/resource"), "/resource");
46+
assertThat(noResourceFoundException.getDetailMessageArguments()).containsExactly("/resource");
47+
}
4348
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/NoResourceFoundException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ public ProblemDetail getBody() {
8080

8181
@Override
8282
public Object[] getDetailMessageArguments() {
83-
return new String[]{this.resourcePath};
83+
return new String[] { this.resourcePath };
8484
}
8585
}

0 commit comments

Comments
 (0)