diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java index 565fa076c5..758865f526 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java @@ -25,10 +25,13 @@ import java.util.NavigableSet; import java.util.Set; import java.util.TreeSet; +import org.springframework.aot.hint.annotation.RegisterReflectionForBinding; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.Selector; import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; +import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevels; +import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevels; import org.springframework.boot.logging.LogLevel; import org.springframework.boot.logging.LoggerConfiguration; import org.springframework.boot.logging.LoggerGroup; @@ -46,6 +49,7 @@ import org.springframework.util.Assert; * @since 2.0.0 */ @Endpoint(id = "loggers") +@RegisterReflectionForBinding({ GroupLoggerLevels.class, SingleLoggerLevels.class }) public class LoggersEndpoint { private final LoggingSystem loggingSystem; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java index 5c7515e3b2..4cd6f2967e 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointTests.java @@ -25,6 +25,10 @@ import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.annotation.ReflectiveRuntimeHintsRegistrar; +import org.springframework.aot.hint.predicate.ReflectionHintsPredicates; +import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; import org.springframework.boot.actuate.logging.LoggersEndpoint.GroupLoggerLevels; import org.springframework.boot.actuate.logging.LoggersEndpoint.LoggerLevels; import org.springframework.boot.actuate.logging.LoggersEndpoint.SingleLoggerLevels; @@ -141,4 +145,19 @@ class LoggersEndpointTests { then(this.loggingSystem).should().setLogLevel("test.member", null); } + @Test + void registersRuntimeHintsForClassesSerializedToJson() { + RuntimeHints runtimeHints = new RuntimeHints(); + new ReflectiveRuntimeHintsRegistrar().registerRuntimeHints(runtimeHints, LoggersEndpoint.class); + ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection(); + assertThat(reflection.onType(LoggerLevels.class)).accepts(runtimeHints); + assertThat(reflection.onMethod(LoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints); + assertThat(reflection.onType(SingleLoggerLevels.class)).accepts(runtimeHints); + assertThat(reflection.onMethod(SingleLoggerLevels.class, "getEffectiveLevel")).accepts(runtimeHints); + assertThat(reflection.onMethod(SingleLoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints); + assertThat(reflection.onType(GroupLoggerLevels.class)).accepts(runtimeHints); + assertThat(reflection.onMethod(GroupLoggerLevels.class, "getMembers")).accepts(runtimeHints); + assertThat(reflection.onMethod(GroupLoggerLevels.class, "getConfiguredLevel")).accepts(runtimeHints); + } + }