diff --git a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java
index 3c58ba2a593..ffdfd89ad06 100644
--- a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java
+++ b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java
@@ -102,7 +102,8 @@ public class ProblemDetail implements Serializable {
/**
* Setter for the {@link #getType() problem type}.
- *
By default, this is not set. According to the spec, when not present, its value is assumed to be "about:blank"
+ *
By default, this is not set. According to the spec, when not present,
+ * the type is assumed to be "about:blank"
* @param type the problem type
*/
public void setType(@Nullable URI type) {
diff --git a/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java b/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java
index 9bf4a0ddd1f..93f25b543b4 100644
--- a/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java
+++ b/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java
@@ -85,7 +85,7 @@ final class DefaultErrorResponseBuilder implements ErrorResponse.Builder {
}
@Override
- public ErrorResponse.Builder type(URI type) {
+ public ErrorResponse.Builder type(@Nullable URI type) {
this.problemDetail.setType(type);
return this;
}
diff --git a/spring-web/src/main/java/org/springframework/web/ErrorResponseException.java b/spring-web/src/main/java/org/springframework/web/ErrorResponseException.java
index f4b29db0a66..5fc792a3980 100644
--- a/spring-web/src/main/java/org/springframework/web/ErrorResponseException.java
+++ b/spring-web/src/main/java/org/springframework/web/ErrorResponseException.java
@@ -111,7 +111,7 @@ public class ErrorResponseException extends NestedRuntimeException implements Er
* Set the {@link ProblemDetail#setType(URI) type} field of the response body.
* @param type the problem type
*/
- public void setType(URI type) {
+ public void setType(@Nullable URI type) {
this.body.setType(type);
}
diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/ProblemDetailJacksonMixinTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/ProblemDetailJacksonMixinTests.java
index 7ab2faaa552..4096c051d81 100644
--- a/spring-web/src/test/java/org/springframework/http/converter/json/ProblemDetailJacksonMixinTests.java
+++ b/spring-web/src/test/java/org/springframework/http/converter/json/ProblemDetailJacksonMixinTests.java
@@ -42,12 +42,11 @@ class ProblemDetailJacksonMixinTests {
@Test
- void writeStatusAndHeaders() throws Exception {
+ void writeStatusAndHeaders() {
ProblemDetail detail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, "Missing header");
testWrite(detail,
"""
{
- "type": "about:blank",
"title": "Bad Request",
"status": 400,
"detail": "Missing header"
@@ -55,14 +54,13 @@ class ProblemDetailJacksonMixinTests {
}
@Test
- void writeCustomProperty() throws Exception {
+ void writeCustomProperty() {
ProblemDetail detail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, "Missing header");
detail.setProperty("host", "abc.org");
detail.setProperty("user", null);
testWrite(detail, """
{
- "type": "about:blank",
"title": "Bad Request",
"status": 400,
"detail": "Missing header",
@@ -72,7 +70,7 @@ class ProblemDetailJacksonMixinTests {
}
@Test
- void readCustomProperty() throws Exception {
+ void readCustomProperty() {
ProblemDetail detail = this.mapper.readValue("""
{
"type": "about:blank",
@@ -93,7 +91,7 @@ class ProblemDetailJacksonMixinTests {
}
@Test
- void readCustomPropertyFromXml() throws Exception {
+ void readCustomPropertyFromXml() {
ObjectMapper xmlMapper = XmlMapper.builder().addMixIn(ProblemDetail.class, ProblemDetailJacksonMixin.class).build();
ProblemDetail detail = xmlMapper.readValue("""
@@ -111,7 +109,7 @@ class ProblemDetailJacksonMixinTests {
assertThat(detail.getProperties()).containsEntry("host", "abc.org");
}
- private void testWrite(ProblemDetail problemDetail, String expected) throws Exception {
+ private void testWrite(ProblemDetail problemDetail, String expected) {
String output = this.mapper.writeValueAsString(problemDetail);
JSONAssert.assertEquals(expected, output, false);
}
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
index 85747f9a5da..aab6f80d9b4 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
@@ -125,8 +125,7 @@ public class DispatcherHandlerErrorTests {
"detail":"No static resource non-existing.",\
"instance":"\\/resources\\/non-existing",\
"status":404,\
- "title":"Not Found",\
- "type":"about:blank"}\
+ "title":"Not Found"}\
""");
}
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
index 477a2caf37c..1ed443e7e96 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
@@ -125,8 +125,7 @@ class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMap
assertThat(ex.getResponseBodyAsString()).isEqualTo("{" +
"\"instance\":\"\\/no-such-handler\"," +
"\"status\":404," +
- "\"title\":\"Not Found\"," +
- "\"type\":\"about:blank\"}");
+ "\"title\":\"Not Found\"}");
});
}
@@ -142,8 +141,7 @@ class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMap
"\"detail\":\"Required query parameter 'q' is not present.\"," +
"\"instance\":\"\\/missing-request-parameter\"," +
"\"status\":400," +
- "\"title\":\"Bad Request\"," +
- "\"type\":\"about:blank\"}");
+ "\"title\":\"Bad Request\"}");
});
}
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java
index 46c3613ec53..714c5cdbdc3 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java
@@ -152,8 +152,7 @@ class ResponseBodyResultHandlerTests {
{\
"status":400,\
"instance":"\\/path",\
- "title":"Bad Request",\
- "type":"about:blank"\
+ "title":"Bad Request"\
}""");
}
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java
index bc6b8f5cff3..9c3932fbb6d 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java
@@ -244,8 +244,7 @@ class ResponseEntityResultHandlerTests {
{\
"instance":"\\/path",\
"status":400,\
- "title":"Bad Request",\
- "type":"about:blank"\
+ "title":"Bad Request"\
}""");
}
@@ -265,8 +264,7 @@ class ResponseEntityResultHandlerTests {
{\
"instance":"\\/path",\
"status":400,\
- "title":"Bad Request",\
- "type":"about:blank"\
+ "title":"Bad Request"\
}""");
}
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java
index 2c1554ec023..4f1eecd9a83 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java
@@ -395,7 +395,6 @@ class RequestResponseBodyMethodProcessorTests {
400
/path
Bad Request
- about:blank
""")
.ignoreWhitespace()
.areIdentical();
@@ -403,7 +402,6 @@ class RequestResponseBodyMethodProcessorTests {
else {
JSONAssert.assertEquals("""
{
- "type": "about:blank",
"title": "Bad Request",
"status": 400,
"instance": "/path"
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java
index 887658fd893..39cc11763f7 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java
@@ -144,8 +144,7 @@ class ResourceHttpRequestHandlerIntegrationTests {
"detail":"No static resource non-existing.",\
"instance":"\\/cp\\/non-existing",\
"status":404,\
- "title":"Not Found",\
- "type":"about:blank"\
+ "title":"Not Found"\
}\
""");
}