Adapt to API change in Spring Framework
See https://github.com/spring-projects/spring-framework/issues/29135
This commit is contained in:
parent
92a0a1d2c6
commit
26cec61f32
|
|
@ -24,6 +24,7 @@ import io.micrometer.core.instrument.Tag;
|
||||||
import io.micrometer.core.instrument.binder.MeterBinder;
|
import io.micrometer.core.instrument.binder.MeterBinder;
|
||||||
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
|
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.HazelcastCacheMeterBinderProviderRuntimeHints;
|
import org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.HazelcastCacheMeterBinderProviderRuntimeHints;
|
||||||
|
|
@ -71,7 +72,8 @@ public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvid
|
||||||
Method getNativeCacheMethod = ReflectionUtils.findMethod(HazelcastCache.class, "getNativeCache");
|
Method getNativeCacheMethod = ReflectionUtils.findMethod(HazelcastCache.class, "getNativeCache");
|
||||||
Assert.state(getNativeCacheMethod != null, "Unable to find 'getNativeCache' method");
|
Assert.state(getNativeCacheMethod != null, "Unable to find 'getNativeCache' method");
|
||||||
Constructor<?> constructor = HazelcastCacheMetrics.class.getConstructor(Object.class, Iterable.class);
|
Constructor<?> constructor = HazelcastCacheMetrics.class.getConstructor(Object.class, Iterable.class);
|
||||||
hints.reflection().registerMethod(getNativeCacheMethod).registerConstructor(constructor);
|
hints.reflection().registerMethod(getNativeCacheMethod, ExecutableMode.INVOKE)
|
||||||
|
.registerConstructor(constructor, ExecutableMode.INVOKE);
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException ex) {
|
catch (NoSuchMethodException ex) {
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import org.springframework.aot.generate.ClassNameGenerator;
|
||||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||||
import org.springframework.aot.generate.FileSystemGeneratedFiles;
|
import org.springframework.aot.generate.FileSystemGeneratedFiles;
|
||||||
import org.springframework.aot.generate.GeneratedFiles.Kind;
|
import org.springframework.aot.generate.GeneratedFiles.Kind;
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
import org.springframework.aot.hint.ReflectionHints;
|
import org.springframework.aot.hint.ReflectionHints;
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
|
@ -154,8 +155,8 @@ public class AotProcessor {
|
||||||
TypeReference applicationType = TypeReference.of(this.application);
|
TypeReference applicationType = TypeReference.of(this.application);
|
||||||
ReflectionHints reflection = generationContext.getRuntimeHints().reflection();
|
ReflectionHints reflection = generationContext.getRuntimeHints().reflection();
|
||||||
reflection.registerType(applicationType);
|
reflection.registerType(applicationType);
|
||||||
reflection.registerType(generatedType,
|
reflection.registerType(generatedType, (typeHint) -> typeHint.onReachableType(applicationType)
|
||||||
(typeHint) -> typeHint.onReachableType(applicationType).withConstructor(Collections.emptyList()));
|
.withConstructor(Collections.emptyList(), ExecutableMode.INVOKE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path getRoot(Kind kind) {
|
private Path getRoot(Kind kind) {
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,11 @@ public final class ConfigurationPropertiesReflectionHintsProcessor {
|
||||||
|
|
||||||
private void handleConstructor(ReflectionHints reflectionHints) {
|
private void handleConstructor(ReflectionHints reflectionHints) {
|
||||||
if (this.bindConstructor != null) {
|
if (this.bindConstructor != null) {
|
||||||
reflectionHints.registerConstructor(this.bindConstructor);
|
reflectionHints.registerConstructor(this.bindConstructor, ExecutableMode.INVOKE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Arrays.stream(this.type.getDeclaredConstructors()).filter(this::hasNoParameters).findFirst()
|
Arrays.stream(this.type.getDeclaredConstructors()).filter(this::hasNoParameters).findFirst()
|
||||||
.ifPresent(reflectionHints::registerConstructor);
|
.ifPresent((constructor) -> reflectionHints.registerConstructor(constructor, ExecutableMode.INVOKE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasNoParameters(Constructor<?> candidate) {
|
private boolean hasNoParameters(Constructor<?> candidate) {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import reactor.netty.http.client.HttpClientRequest;
|
import reactor.netty.http.client.HttpClientRequest;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
|
@ -803,9 +804,10 @@ public class RestTemplateBuilder {
|
||||||
ReflectionUtils.findField(AbstractClientHttpRequestFactoryWrapper.class, "requestFactory")));
|
ReflectionUtils.findField(AbstractClientHttpRequestFactoryWrapper.class, "requestFactory")));
|
||||||
ClientHttpRequestFactorySupplier.ClientHttpRequestFactorySupplierRuntimeHints.registerHints(hints,
|
ClientHttpRequestFactorySupplier.ClientHttpRequestFactorySupplierRuntimeHints.registerHints(hints,
|
||||||
classLoader, (hint) -> {
|
classLoader, (hint) -> {
|
||||||
hint.withMethod("setConnectTimeout", TypeReference.listOf(int.class));
|
hint.withMethod("setConnectTimeout", TypeReference.listOf(int.class), ExecutableMode.INVOKE);
|
||||||
hint.withMethod("setReadTimeout", TypeReference.listOf(int.class));
|
hint.withMethod("setReadTimeout", TypeReference.listOf(int.class), ExecutableMode.INVOKE);
|
||||||
hint.withMethod("setBufferRequestBody", TypeReference.listOf(boolean.class));
|
hint.withMethod("setBufferRequestBody", TypeReference.listOf(boolean.class),
|
||||||
|
ExecutableMode.INVOKE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue