Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.jspecify.annotations.Nullable;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.BindingReflectionHintsRegistrar;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
Expand All @@ -42,6 +42,7 @@
*
* @author Gary Russell
* @author Sagnhyeok An
* @author Soby Chacko
* @since 3.0
*
*/
Expand All @@ -55,6 +56,8 @@ public class KafkaAvroBeanRegistrationAotProcessor implements BeanRegistrationAo

private static final boolean AVRO_PRESENT = ClassUtils.isPresent(AVRO_GENERATED_CLASS_NAME, null);

private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();

@Override
public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
if (!AVRO_PRESENT) {
Expand Down Expand Up @@ -83,9 +86,7 @@ public class KafkaAvroBeanRegistrationAotProcessor implements BeanRegistrationAo
if (!avroTypes.isEmpty()) {
return (generationContext, beanRegistrationCode) -> {
ReflectionHints reflectionHints = generationContext.getRuntimeHints().reflection();
avroTypes.forEach(type -> reflectionHints.registerType(type,
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_PUBLIC_METHODS)));
this.bindingRegistrar.registerReflectionHints(reflectionHints, avroTypes.toArray(new Class<?>[0]));
};
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.common.message.CreateTopicsRequestData.CreatableTopic;
import org.apache.kafka.common.protocol.Message;
import org.apache.kafka.common.security.oauthbearer.DefaultJwtRetriever;
import org.apache.kafka.common.serialization.Serdes;
import org.apache.kafka.common.utils.AppInfoParser.AppInfo;
import org.apache.kafka.common.utils.ImplicitLinkedHashCollection;
Expand Down Expand Up @@ -87,6 +88,8 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)));

Stream.of(
// Following Kafka classes need to be ideally part of Oracle's reachability metadata repository.
DefaultJwtRetriever.class,
Message.class,
ImplicitLinkedHashCollection.Element.class,
NewTopic.class,
Expand Down
Loading