Browse Source

Allow Info to be built with null map values

See gh-48480

Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
pull/48484/head
Tran Ngoc Nhan 1 week ago committed by Phillip Webb
parent
commit
d00cb0b282
  1. 4
      module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/Info.java
  2. 4
      module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/MapInfoContributor.java

4
module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/Info.java

@ -93,7 +93,7 @@ public final class Info {
*/ */
public static class Builder { public static class Builder {
private final Map<String, Object> content; private final Map<String, @Nullable Object> content;
public Builder() { public Builder() {
this.content = new LinkedHashMap<>(); this.content = new LinkedHashMap<>();
@ -116,7 +116,7 @@ public final class Info {
* @return this {@link Builder} instance * @return this {@link Builder} instance
* @see #withDetail(String, Object) * @see #withDetail(String, Object)
*/ */
public Builder withDetails(Map<String, @Nullable ? extends Object> details) { public Builder withDetails(Map<String, @Nullable Object> details) {
this.content.putAll(details); this.content.putAll(details);
return this; return this;
} }

4
module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/MapInfoContributor.java

@ -19,6 +19,8 @@ package org.springframework.boot.actuate.info;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.jspecify.annotations.Nullable;
/** /**
* A simple {@link InfoContributor} that exposes a map. * A simple {@link InfoContributor} that exposes a map.
* *
@ -27,7 +29,7 @@ import java.util.Map;
*/ */
public class MapInfoContributor implements InfoContributor { public class MapInfoContributor implements InfoContributor {
private final Map<String, Object> info; private final Map<String, @Nullable Object> info;
public MapInfoContributor(Map<String, Object> info) { public MapInfoContributor(Map<String, Object> info) {
this.info = new LinkedHashMap<>(info); this.info = new LinkedHashMap<>(info);

Loading…
Cancel
Save