2424import org .springframework .aot .hint .RuntimeHints ;
2525import org .springframework .aot .hint .RuntimeHintsRegistrar ;
2626import 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