Merge branch '5.3.x'

# Conflicts:
#	spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
This commit is contained in:
Juergen Hoeller
2021-09-28 18:18:23 +02:00
6 changed files with 47 additions and 14 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.core.env.StandardEnvironment;
import org.springframework.jndi.JndiLocatorDelegate;
import org.springframework.jndi.JndiPropertySource;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.web.context.ConfigurableWebEnvironment;
/**
@@ -39,6 +40,7 @@ import org.springframework.web.context.ConfigurableWebEnvironment;
* documentation for details.
*
* @author Chris Beams
* @author Juergen Hoeller
* @since 3.1
* @see StandardEnvironment
*/
@@ -54,6 +56,11 @@ public class StandardServletEnvironment extends StandardEnvironment implements C
public static final String JNDI_PROPERTY_SOURCE_NAME = "jndiProperties";
// Defensive reference to JNDI API for JDK 9+ (optional java.naming module)
private static final boolean jndiPresent = ClassUtils.isPresent(
"javax.naming.InitialContext", StandardServletEnvironment.class.getClassLoader());
/**
* Create a new {@code StandardServletEnvironment} instance.
*/
@@ -100,7 +107,7 @@ public class StandardServletEnvironment extends StandardEnvironment implements C
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addLast(new StubPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME));
propertySources.addLast(new StubPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME));
if (JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
if (jndiPresent && JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()) {
propertySources.addLast(new JndiPropertySource(JNDI_PROPERTY_SOURCE_NAME));
}
super.customizePropertySources(propertySources);