Fix AOT processing of add method with array parameter in Logback model
Fixes gh-33387
This commit is contained in:
@@ -291,7 +291,8 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
|
||||
.filter((method) -> !method.getDeclaringClass().equals(ContextAware.class)
|
||||
&& !method.getDeclaringClass().equals(ContextAwareBase.class))
|
||||
.map(Method::getParameterTypes).flatMap(Stream::of)
|
||||
.filter((type) -> !type.isPrimitive() && !type.equals(String.class)).map(Class::getName).toList();
|
||||
.filter((type) -> !type.isPrimitive() && !type.equals(String.class))
|
||||
.map((type) -> type.isArray() ? type.getComponentType() : type).map(Class::getName).toList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.logging.logback;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -178,6 +179,15 @@ class LogbackConfigurationAotContributionTests {
|
||||
.accepts(generationContext.getRuntimeHints());
|
||||
}
|
||||
|
||||
@Test
|
||||
void componentTypesOfArraysAreRegisteredForReflection() {
|
||||
ComponentModel component = new ComponentModel();
|
||||
component.setClassName(ArrayParmeters.class.getName());
|
||||
TestGenerationContext generationContext = applyContribution(component);
|
||||
assertThat(invokePublicConstructorsAndInspectAndInvokePublicMethodsOf(InetSocketAddress.class))
|
||||
.accepts(generationContext.getRuntimeHints());
|
||||
}
|
||||
|
||||
private Predicate<RuntimeHints> invokePublicConstructorsOf(String name) {
|
||||
return RuntimeHintsPredicates.reflection().onType(TypeReference.of(name))
|
||||
.withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
@@ -254,4 +264,12 @@ class LogbackConfigurationAotContributionTests {
|
||||
|
||||
}
|
||||
|
||||
public static class ArrayParmeters {
|
||||
|
||||
public void addDestinations(InetSocketAddress... addresses) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user