GH-3875: Initialize ClassUtils as early as possible

Fixes https://github.com/spring-projects/spring-integration/issues/3875

The class `static` variables and initialization block are performed on first class access.

* Add "fake" `ClassUtils.resolvePrimitiveType(Integer.class)` call to the `IntegrationRegistrar`
to trigger `ClassUtils` initialization with the current Spring `ClassLoader`

**Cherry-pick to `5.5.x`**
This commit is contained in:
Artem Bilan
2022-08-17 12:54:51 -04:00
committed by Gary Russell
parent 718d8a43a7
commit b7710fcd4d

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,9 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar {
public void registerBeanDefinitions(@Nullable AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
// Ensure that ClassUtils is initialized with a proper Spring application context ClassLoader.
org.springframework.integration.util.ClassUtils.resolvePrimitiveType(Integer.class);
registerDefaultConfiguringBeanFactoryPostProcessor(registry);
registerIntegrationConfigurationBeanFactoryPostProcessor(registry);
if (importingClassMetadata != null) {