Skip to content

Commit febecbd

Browse files
authored
GH-4190: Add DefaultJwtValidator to runtime hints
Fixes: #4190 Signed-off-by: waileong <wai_leong1015@hotmail.com>
1 parent 98b99a5 commit febecbd

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

spring-kafka/src/main/java/org/springframework/kafka/aot/KafkaRuntimeHints.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.kafka.common.message.CreateTopicsRequestData.CreatableTopic;
2626
import org.apache.kafka.common.protocol.Message;
2727
import org.apache.kafka.common.security.oauthbearer.DefaultJwtRetriever;
28+
import org.apache.kafka.common.security.oauthbearer.DefaultJwtValidator;
2829
import org.apache.kafka.common.serialization.Serdes;
2930
import org.apache.kafka.common.utils.AppInfoParser.AppInfo;
3031
import org.apache.kafka.common.utils.ImplicitLinkedHashCollection;
@@ -90,6 +91,7 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
9091
Stream.of(
9192
// Following Kafka classes need to be ideally part of Oracle's reachability metadata repository.
9293
DefaultJwtRetriever.class,
94+
DefaultJwtValidator.class,
9395
Message.class,
9496
ImplicitLinkedHashCollection.Element.class,
9597
NewTopic.class,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2018-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.kafka.aot;
18+
19+
import org.apache.kafka.common.security.oauthbearer.DefaultJwtValidator;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.aot.hint.MemberCategory;
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
/**
29+
* @author Wai Leong
30+
* @since 4.0.1
31+
*/
32+
class KafkaRuntimeHintsTest {
33+
34+
@Test
35+
void shouldRegisterDefaultJwtValidatorRuntimeHints() {
36+
RuntimeHints hints = new RuntimeHints();
37+
new KafkaRuntimeHints().registerHints(hints, getClass().getClassLoader());
38+
assertThat(RuntimeHintsPredicates.reflection().onType(DefaultJwtValidator.class)
39+
.withMemberCategories(
40+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
41+
MemberCategory.INVOKE_DECLARED_METHODS))
42+
.accepts(hints);
43+
}
44+
}

0 commit comments

Comments
 (0)