From 15931532cd6539be5f7a49f8e566571ad4089cdc Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Mon, 30 Jan 2023 16:48:57 +0000 Subject: [PATCH] Polishing contribution Closes gh-29868 --- .../main/java/org/springframework/http/ProblemDetail.java | 5 +++-- .../http/converter/json/ProblemDetailJacksonMixin.java | 2 +- .../org/springframework/web/DefaultErrorResponseBuilder.java | 4 ++-- .../src/main/java/org/springframework/web/ErrorResponse.java | 4 ++-- .../http/converter/json/ProblemDetailJacksonMixinTests.java | 2 +- 5 files changed, 9 insertions(+), 8 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 2a8ff81432a..3b0ee036f6b 100644 --- a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java +++ b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -206,7 +206,8 @@ public class ProblemDetail { * are rendered as top level key-value pairs in the output JSON. Otherwise, * they are rendered as a {@code "properties"} sub-map. * @param name the property name - * @param value the property value + * @param value the property value, possibly {@code null} if the intent is + * to include a property with its value set to "null" * @see org.springframework.http.converter.json.ProblemDetailJacksonMixin */ public void setProperty(String name, @Nullable Object value) { diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonMixin.java b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonMixin.java index 0fcb96b036a..27b49005a3d 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonMixin.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailJacksonMixin.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 58c30a8e7a5..ae2725b632c 100644 --- a/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/DefaultErrorResponseBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ final class DefaultErrorResponseBuilder implements ErrorResponse.Builder { } @Override - public ErrorResponse.Builder property(String name, Object value) { + public ErrorResponse.Builder property(String name, @Nullable Object value) { this.problemDetail.setProperty(name, value); return this; } diff --git a/spring-web/src/main/java/org/springframework/web/ErrorResponse.java b/spring-web/src/main/java/org/springframework/web/ErrorResponse.java index 0b3c200292d..adbbfc42b84 100644 --- a/spring-web/src/main/java/org/springframework/web/ErrorResponse.java +++ b/spring-web/src/main/java/org/springframework/web/ErrorResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -265,7 +265,7 @@ public interface ErrorResponse { * property} on the underlying {@code ProblemDetail}. * @return the same builder instance */ - Builder property(String name, Object value); + Builder property(String name, @Nullable Object value); /** * Build the {@code ErrorResponse} instance. 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 5058485df12..f521cb023ae 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.