Spring boot autoconfigured ElasticsearchRestTemplate class causes following log output when handling an entity having BigDecimal field:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/C:/Users/demo/.m2/repository/org/springframework/spring-core/5.3.3/spring-core-5.3.3.jar) to field java.math.BigDecimal.intVal
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Trivial demo program demo.zip Please see single unit test. It fails because of no connection, but subject warnings are logged before.

My investigation Looks like that the problem is BigDecimal being treated as non-simple type by SimpleTypeHolder, that leads to attempt to do reflection on BigDecimal. It should be simple because elastic module has a converter for BigDecimal. BigDecimal is not in a simple type list because of SimpleElasticsearchMappingContext initialization. In spring-data-elasticsearch (ElasticsearchConfigurationSupport) after initialization mappingContext.setSimpleTypeHolder(elasticsearchCustomConversions.getSimpleTypeHolder()); is called, but in spring boot autoconfiguration it is not.

Workaround

@Configuration
@Import(ElasticsearchConfigurationSupport.class)
public class ElasticsearchConfiguration {}

It overrides beans from spring boot with beans from spring-data-elasticsearch class ElasticsearchConfigurationSupport, that initializes simple type list properly.

Comment From: snicoll

Good catch @crazyjurich, thank you. I've found another inconsistent related to document scanning, see #26028.