This commit is contained in:
Phillip Webb
2022-07-29 12:07:36 +01:00
parent 41e8697445
commit e08c16dfd6
17 changed files with 134 additions and 111 deletions

View File

@@ -16,11 +16,11 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.reactivestreams.Publisher;
@@ -44,6 +44,7 @@ import org.springframework.context.aot.BindingReflectionHintsRegistrar;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping;
@@ -159,8 +160,10 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerMethod(Objects.requireNonNull(
ReflectionUtils.findMethod(CloudFoundryLinksHandler.class, "links", ServerWebExchange.class)));
Method linksMethod = ReflectionUtils.findMethod(CloudFoundryLinksHandler.class, "links",
ServerWebExchange.class);
Assert.state(linksMethod != null, "Unable to find 'links' method");
hints.reflection().registerMethod(linksMethod);
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
}

View File

@@ -16,11 +16,11 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
@@ -45,6 +45,7 @@ import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.cors.CorsConfiguration;
@@ -161,9 +162,10 @@ class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpoin
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection()
.registerMethod(Objects.requireNonNull(ReflectionUtils.findMethod(CloudFoundryLinksHandler.class,
"links", HttpServletRequest.class, HttpServletResponse.class)));
Method linksMethod = ReflectionUtils.findMethod(CloudFoundryLinksHandler.class, "links",
HttpServletRequest.class, HttpServletResponse.class);
Assert.state(linksMethod != null, "Unable to find 'links' method");
hints.reflection().registerMethod(linksMethod);
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
}

View File

@@ -40,7 +40,6 @@ class ActuatorAnnotationsRuntimeHints implements RuntimeHintsRegistrar {
Stream.of(Endpoint.class, ReadOperation.class, WriteOperation.class, DeleteOperation.class,
EndpointExtension.class)
.forEach((annotationType) -> RuntimeHintsUtils.registerAnnotation(hints, annotationType));
// TODO: See https://github.com/spring-projects/spring-framework/issues/28767
Stream.of(Endpoint.class, EndpointExtension.class).forEach(
(annotationType) -> hints.proxies().registerJdkProxy(annotationType, SynthesizedAnnotation.class));
}