Skip to content

Commit

Permalink
Merge branch '3.4.x'
Browse files Browse the repository at this point in the history
Closes gh-44440
  • Loading branch information
mhalbritter committed Feb 26, 2025
2 parents e7d9f19 + 8705ed0 commit 79ec0ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.config.SslConfigs;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand All @@ -42,6 +45,7 @@
import org.springframework.boot.ssl.SslBundles;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
Expand Down Expand Up @@ -78,6 +82,7 @@
@ConditionalOnClass(KafkaTemplate.class)
@EnableConfigurationProperties(KafkaProperties.class)
@Import({ KafkaAnnotationDrivenConfiguration.class, KafkaStreamsAnnotationDrivenConfiguration.class })
@ImportRuntimeHints(KafkaAutoConfiguration.KafkaRuntimeHints.class)
public class KafkaAutoConfiguration {

private final KafkaProperties properties;
Expand Down Expand Up @@ -249,4 +254,13 @@ static void applySecurityProtocol(Map<String, Object> properties, String securit
}
}

static class KafkaRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(SslBundleSslEngineFactory.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.ssl.SslBundle;
Expand Down Expand Up @@ -992,6 +995,15 @@ void specificSecurityProtocolOverridesCommonSecurityProtocol() {
});
}

@Test
void shouldRegisterRuntimeHints() {
RuntimeHints runtimeHints = new RuntimeHints();
new KafkaAutoConfiguration.KafkaRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
assertThat(RuntimeHintsPredicates.reflection()
.onType(SslBundleSslEngineFactory.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)).accepts(runtimeHints);
}

private KafkaConnectionDetails kafkaConnectionDetails() {
return new KafkaConnectionDetails() {

Expand Down

0 comments on commit 79ec0ea

Please sign in to comment.