Skip to content

Commit b3bd77a

Browse files
committed
Adjust aot hints for Elasticsearch 9 client.
The hints for the old httpclient are only needed when the old library is on the classpath, in case a user still uses the old RestClient. For the new Elasticsearch client there are no aot hints required. Closes: #3203 Signed-off-by: Peter-Josef Meisch <[email protected]> (cherry picked from commit e31b667)
1 parent bea651b commit b3bd77a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/main/java/org/springframework/data/elasticsearch/client/elc/aot/ElasticsearchClientRuntimeHints.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.aot.hint.RuntimeHints;
2525
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2626
import org.springframework.aot.hint.TypeReference;
27+
import org.springframework.util.ClassUtils;
2728

2829
/**
2930
* runtime hints for the Elasticsearch client libraries, as these do not provide any of their own.
@@ -37,20 +38,20 @@ public class ElasticsearchClientRuntimeHints implements RuntimeHintsRegistrar {
3738
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
3839

3940
hints.reflection()
40-
.registerType(TypeReference.of(IndexSettings.class), builder -> builder.withField("_DESERIALIZER")) //
41-
.registerType(TypeReference.of(PutMappingRequest.class), builder -> builder.withField("_DESERIALIZER")) //
42-
.registerType(TypeReference.of(RuntimeFieldType.class), builder -> builder.withField("_DESERIALIZER"))//
43-
.registerType(TypeReference.of(TypeMapping.class), builder -> builder.withField("_DESERIALIZER")) //
44-
;
41+
.registerType(TypeReference.of(IndexSettings.class), builder -> builder.withField("_DESERIALIZER"))
42+
.registerType(TypeReference.of(PutMappingRequest.class), builder -> builder.withField("_DESERIALIZER"))
43+
.registerType(TypeReference.of(RuntimeFieldType.class), builder -> builder.withField("_DESERIALIZER"))
44+
.registerType(TypeReference.of(TypeMapping.class), builder -> builder.withField("_DESERIALIZER"));
4545

46-
hints.serialization() //
47-
.registerType(org.apache.http.impl.auth.BasicScheme.class) //
48-
.registerType(org.apache.http.impl.auth.RFC2617Scheme.class) //
49-
.registerType(java.util.HashMap.class) //
50-
;
46+
if (ClassUtils.isPresent("org.apache.http.impl.auth.BasicScheme",
47+
ElasticsearchClientRuntimeHints.class.getClassLoader())) {
48+
hints.serialization()
49+
.registerType(org.apache.http.impl.auth.BasicScheme.class)
50+
.registerType(org.apache.http.impl.auth.RFC2617Scheme.class)
51+
.registerType(java.util.HashMap.class);
52+
}
5153

5254
hints.resources() //
53-
.registerPattern("co/elastic/clients/version.properties") //
54-
;
55+
.registerPattern("co/elastic/clients/version.properties");
5556
}
5657
}

0 commit comments

Comments
 (0)