Skip to content

Make type in ProblemDetail nullable #35294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -104,18 +102,17 @@ protected ProblemDetail() {

/**
* Setter for the {@link #getType() problem type}.
* <p>By default, this is {@link #BLANK_TYPE}.
* <p>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(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;
}

Expand Down Expand Up @@ -245,7 +242,7 @@ public void setProperties(@Nullable Map<String, Object> 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) &&
Expand Down