From 91f2c25731c0717f26856050faa8a8f8f6c6a711 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 6 Aug 2025 14:08:49 +0200 Subject: [PATCH 1/2] Make `type` in `ProblemDetail` nullable Signed-off-by: Christoph Wagner Signed-off-by: Christoph --- .../main/java/org/springframework/http/ProblemDetail.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 617c4fd684d7..b00cc1b7cbcb 100644 --- a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java +++ b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java @@ -107,15 +107,14 @@ protected ProblemDetail() { *

By default, this is {@link #BLANK_TYPE}. * @param type the problem type */ - public void setType(URI type) { - Assert.notNull(type, "'type' is required"); + public void setType(@Nullable URI type) { this.type = type; } /** * Return the configured {@link #setType(URI) problem type}. */ - public URI getType() { + public @Nullable URI getType() { return this.type; } @@ -245,7 +244,7 @@ public void setProperties(@Nullable Map properties) { @Override public boolean equals(@Nullable Object other) { return (this == other || (other instanceof ProblemDetail that && - getType().equals(that.getType()) && + ObjectUtils.nullSafeEquals(getType(), that.getType()) && ObjectUtils.nullSafeEquals(getTitle(), that.getTitle()) && this.status == that.status && ObjectUtils.nullSafeEquals(this.detail, that.detail) && From f725ea9d28ded1d4490589b4b765549b18764550 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Fri, 8 Aug 2025 10:31:10 +0200 Subject: [PATCH 2/2] Remove default type of "about:blank" in `ProblemDetail` Signed-off-by: Christoph Wagner --- .../main/java/org/springframework/http/ProblemDetail.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 b00cc1b7cbcb..3c58ba2a593d 100644 --- a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java +++ b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java @@ -55,10 +55,8 @@ public class ProblemDetail implements Serializable { private static final long serialVersionUID = 3307761915842206538L; - private static final URI BLANK_TYPE = URI.create("about:blank"); - - private URI type = BLANK_TYPE; + private @Nullable URI type; private @Nullable String title; @@ -104,7 +102,7 @@ protected ProblemDetail() { /** * Setter for the {@link #getType() problem type}. - *

By default, this is {@link #BLANK_TYPE}. + *

By default, this is not set. According to the spec, when not present, its value is assumed to be "about:blank" * @param type the problem type */ public void setType(@Nullable URI type) {