From 16325c2eaaa6bc6c87a7e4b720dc281aca52ce8b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 20 Sep 2014 00:29:16 +0200 Subject: [PATCH] Polishing --- .../annotation/ConfigurationClassParser.java | 2 +- .../jndi/JndiPropertySource.java | 16 +-- ...onmentSecurityManagerIntegrationTests.java | 29 +++--- .../jndi/SimpleNamingContextTests.java | 73 +++++++------- .../mock/jndi/SimpleNamingContextBuilder.java | 17 ++-- .../core/env/AbstractEnvironment.java | 80 ++++++++------- .../core/env/AbstractPropertyResolver.java | 97 +++++++++++-------- .../core/env/CommandLinePropertySource.java | 6 +- .../env/ConfigurablePropertyResolver.java | 27 +++--- .../mock/jndi/SimpleNamingContextBuilder.java | 10 +- 10 files changed, 186 insertions(+), 171 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 2dd2a20df29..a25ae12b4da 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -375,7 +375,7 @@ class ConfigurationClassParser { propertySources.addLast(propertySource); } else { - String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size()-1); + String firstProcessed = this.propertySourceNames.get(this.propertySourceNames.size() - 1); propertySources.addBefore(firstProcessed, propertySource); } } diff --git a/spring-context/src/main/java/org/springframework/jndi/JndiPropertySource.java b/spring-context/src/main/java/org/springframework/jndi/JndiPropertySource.java index 46886023a44..b33fc6d8858 100644 --- a/spring-context/src/main/java/org/springframework/jndi/JndiPropertySource.java +++ b/spring-context/src/main/java/org/springframework/jndi/JndiPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2014 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. @@ -69,9 +69,9 @@ public class JndiPropertySource extends PropertySource { super(name, jndiLocator); } + /** - * {@inheritDoc} - *

This implementation looks up and returns the value associated with the given + * This implementation looks up and returns the value associated with the given * name from the underlying {@link JndiLocatorDelegate}. If a {@link NamingException} * is thrown during the call to {@link JndiLocatorDelegate#lookup(String)}, returns * {@code null} and issues a DEBUG-level log statement with the exception message. @@ -80,12 +80,16 @@ public class JndiPropertySource extends PropertySource { public Object getProperty(String name) { try { Object value = this.source.lookup(name); - logger.debug("JNDI lookup for name [" + name + "] returned: [" + value + "]"); + if (logger.isDebugEnabled()) { + logger.debug("JNDI lookup for name [" + name + "] returned: [" + value + "]"); + } return value; } catch (NamingException ex) { - logger.debug("JNDI lookup for name [" + name + "] threw NamingException " + - "with message: " + ex.getMessage() + ". Returning null."); + if (logger.isDebugEnabled()) { + logger.debug("JNDI lookup for name [" + name + "] threw NamingException " + + "with message: " + ex.getMessage() + ". Returning null."); + } return null; } } diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java index 474b5943392..7f202aa473a 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -16,10 +16,6 @@ package org.springframework.context.support; -import static java.lang.String.format; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - import java.security.AccessControlException; import java.security.Permission; import java.util.Map; @@ -35,6 +31,10 @@ import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.StandardEnvironmentTests; import org.springframework.stereotype.Component; +import static java.lang.String.format; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + /** * Tests integration between Environment and SecurityManagers. See SPR-9970. * @@ -43,8 +43,10 @@ import org.springframework.stereotype.Component; public class EnvironmentSecurityManagerIntegrationTests { private SecurityManager originalSecurityManager; + private Map env; + @Before public void setUp() { originalSecurityManager = System.getSecurityManager(); @@ -58,16 +60,16 @@ public class EnvironmentSecurityManagerIntegrationTests { System.setSecurityManager(originalSecurityManager); } + @Test public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() { SecurityManager securityManager = new SecurityManager() { @Override public void checkPermission(Permission perm) { - // disallowing access to System#getenv means that our + // Disallowing access to System#getenv means that our // ReadOnlySystemAttributesMap will come into play. if ("getenv.*".equals(perm.getName())) { - throw new AccessControlException( - "Accessing the system environment is disallowed"); + throw new AccessControlException("Accessing the system environment is disallowed"); } } }; @@ -84,18 +86,17 @@ public class EnvironmentSecurityManagerIntegrationTests { SecurityManager securityManager = new SecurityManager() { @Override public void checkPermission(Permission perm) { - // disallowing access to System#getenv means that our + // Disallowing access to System#getenv means that our // ReadOnlySystemAttributesMap will come into play. if ("getenv.*".equals(perm.getName())) { - throw new AccessControlException( - "Accessing the system environment is disallowed"); + throw new AccessControlException("Accessing the system environment is disallowed"); } - // disallowing access to the spring.profiles.active property means that + // Disallowing access to the spring.profiles.active property means that // the BeanDefinitionReader won't be able to determine which profiles are // active. We should see an INFO-level message in the console about this // and as a result, any components marked with a non-default profile will // be ignored. - if (("getenv."+AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) { + if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) { throw new AccessControlException( format("Accessing system environment variable [%s] is disallowed", AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME)); @@ -110,8 +111,10 @@ public class EnvironmentSecurityManagerIntegrationTests { assertThat(bf.containsBean("c1"), is(false)); } + @Component("c1") @Profile("p1") static class C1 { } + } diff --git a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java index 51ea8e86af6..15bd7ba0959 100644 --- a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -214,52 +214,53 @@ public class SimpleNamingContextTests { assertEquals(ctx.lookup(name), o2); } -} -class StubDataSource implements DataSource { + static class StubDataSource implements DataSource { - @Override - public Connection getConnection() throws SQLException { - return null; - } + @Override + public Connection getConnection() throws SQLException { + return null; + } - @Override - public Connection getConnection(String username, String password) throws SQLException { - return null; - } + @Override + public Connection getConnection(String username, String password) throws SQLException { + return null; + } - @Override - public PrintWriter getLogWriter() throws SQLException { - return null; - } + @Override + public PrintWriter getLogWriter() throws SQLException { + return null; + } - @Override - public int getLoginTimeout() throws SQLException { - return 0; - } + @Override + public int getLoginTimeout() throws SQLException { + return 0; + } - @Override - public void setLogWriter(PrintWriter arg0) throws SQLException { + @Override + public void setLogWriter(PrintWriter arg0) throws SQLException { - } + } - @Override - public void setLoginTimeout(int arg0) throws SQLException { + @Override + public void setLoginTimeout(int arg0) throws SQLException { - } + } - @Override - public boolean isWrapperFor(Class arg0) throws SQLException { - return false; - } + @Override + public boolean isWrapperFor(Class arg0) throws SQLException { + return false; + } - @Override - public T unwrap(Class arg0) throws SQLException { - return null; - } + @Override + public T unwrap(Class arg0) throws SQLException { + return null; + } - @Override - public Logger getParentLogger() { - return null; + @Override + public Logger getParentLogger() { + return null; + } } + } diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java index 3d1452ac29f..1ae3b78d6b1 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java +++ b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -17,7 +17,6 @@ package org.springframework.tests.mock.jndi; import java.util.Hashtable; - import javax.naming.Context; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; @@ -40,9 +39,9 @@ import org.springframework.util.ClassUtils; * *

There are various choices for DataSource implementations: *

* *

Typical usage in bootstrap code: @@ -77,7 +76,6 @@ import org.springframework.util.ClassUtils; * @see SimpleNamingContext * @see org.springframework.jdbc.datasource.SingleConnectionDataSource * @see org.springframework.jdbc.datasource.DriverManagerDataSource - * @see org.apache.commons.dbcp.BasicDataSource */ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder { @@ -197,7 +195,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder if (activated == null && environment != null) { Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY); if (icf != null) { - Class icfClass = null; + Class icfClass; if (icf instanceof Class) { icfClass = (Class) icf; } @@ -216,10 +214,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder return (InitialContextFactory) icfClass.newInstance(); } catch (Throwable ex) { - IllegalStateException ise = - new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf); - ise.initCause(ex); - throw ise; + throw new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf, ex); } } } diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index d5a195aacca..b7918aee17d 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -295,7 +295,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { } /** - * {@inheritDoc} + * Specify the set of profiles to be made active by default if no other profiles + * are explicitly made active through {@link #setActiveProfiles}. *

Calling this method removes overrides any reserved default profiles * that may have been added during construction of the environment. * @see #AbstractEnvironment() @@ -456,93 +457,98 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { //--------------------------------------------------------------------- @Override - public boolean containsProperty(String key) { - return this.propertyResolver.containsProperty(key); + public ConfigurableConversionService getConversionService() { + return this.propertyResolver.getConversionService(); } @Override - public String getProperty(String key) { - return this.propertyResolver.getProperty(key); + public void setConversionService(ConfigurableConversionService conversionService) { + this.propertyResolver.setConversionService(conversionService); } @Override - public String getProperty(String key, String defaultValue) { - return this.propertyResolver.getProperty(key, defaultValue); + public void setPlaceholderPrefix(String placeholderPrefix) { + this.propertyResolver.setPlaceholderPrefix(placeholderPrefix); } @Override - public T getProperty(String key, Class targetType) { - return this.propertyResolver.getProperty(key, targetType); + public void setPlaceholderSuffix(String placeholderSuffix) { + this.propertyResolver.setPlaceholderSuffix(placeholderSuffix); } @Override - public T getProperty(String key, Class targetType, T defaultValue) { - return this.propertyResolver.getProperty(key, targetType, defaultValue); + public void setValueSeparator(String valueSeparator) { + this.propertyResolver.setValueSeparator(valueSeparator); } @Override - public Class getPropertyAsClass(String key, Class targetType) { - return this.propertyResolver.getPropertyAsClass(key, targetType); + public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) { + this.propertyResolver.setIgnoreUnresolvableNestedPlaceholders(ignoreUnresolvableNestedPlaceholders); } @Override - public String getRequiredProperty(String key) throws IllegalStateException { - return this.propertyResolver.getRequiredProperty(key); + public void setRequiredProperties(String... requiredProperties) { + this.propertyResolver.setRequiredProperties(requiredProperties); } @Override - public T getRequiredProperty(String key, Class targetType) throws IllegalStateException { - return this.propertyResolver.getRequiredProperty(key, targetType); + public void validateRequiredProperties() throws MissingRequiredPropertiesException { + this.propertyResolver.validateRequiredProperties(); } + + //--------------------------------------------------------------------- + // Implementation of PropertyResolver interface + //--------------------------------------------------------------------- + @Override - public void setRequiredProperties(String... requiredProperties) { - this.propertyResolver.setRequiredProperties(requiredProperties); + public boolean containsProperty(String key) { + return this.propertyResolver.containsProperty(key); } @Override - public void validateRequiredProperties() throws MissingRequiredPropertiesException { - this.propertyResolver.validateRequiredProperties(); + public String getProperty(String key) { + return this.propertyResolver.getProperty(key); } @Override - public String resolvePlaceholders(String text) { - return this.propertyResolver.resolvePlaceholders(text); + public String getProperty(String key, String defaultValue) { + return this.propertyResolver.getProperty(key, defaultValue); } @Override - public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException { - return this.propertyResolver.resolveRequiredPlaceholders(text); + public T getProperty(String key, Class targetType) { + return this.propertyResolver.getProperty(key, targetType); } @Override - public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) { - this.propertyResolver.setIgnoreUnresolvableNestedPlaceholders(ignoreUnresolvableNestedPlaceholders); + public T getProperty(String key, Class targetType, T defaultValue) { + return this.propertyResolver.getProperty(key, targetType, defaultValue); } @Override - public void setConversionService(ConfigurableConversionService conversionService) { - this.propertyResolver.setConversionService(conversionService); + public Class getPropertyAsClass(String key, Class targetType) { + return this.propertyResolver.getPropertyAsClass(key, targetType); } @Override - public ConfigurableConversionService getConversionService() { - return this.propertyResolver.getConversionService(); + public String getRequiredProperty(String key) throws IllegalStateException { + return this.propertyResolver.getRequiredProperty(key); } @Override - public void setPlaceholderPrefix(String placeholderPrefix) { - this.propertyResolver.setPlaceholderPrefix(placeholderPrefix); + public T getRequiredProperty(String key, Class targetType) throws IllegalStateException { + return this.propertyResolver.getRequiredProperty(key, targetType); } @Override - public void setPlaceholderSuffix(String placeholderSuffix) { - this.propertyResolver.setPlaceholderSuffix(placeholderSuffix); + public String resolvePlaceholders(String text) { + return this.propertyResolver.resolvePlaceholders(text); } @Override - public void setValueSeparator(String valueSeparator) { - this.propertyResolver.setValueSeparator(valueSeparator); + public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException { + return this.propertyResolver.resolveRequiredPlaceholders(text); } diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java index 2d1bcf022bf..b5f18271cf4 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java @@ -65,16 +65,50 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe this.conversionService = conversionService; } + /** + * Set the prefix that placeholders replaced by this resolver must begin with. + *

The default is "${". + * @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX + */ @Override - public String getProperty(String key, String defaultValue) { - String value = getProperty(key); - return (value != null ? value : defaultValue); + public void setPlaceholderPrefix(String placeholderPrefix) { + this.placeholderPrefix = placeholderPrefix; } + /** + * Set the suffix that placeholders replaced by this resolver must end with. + *

The default is "}". + * @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX + */ @Override - public T getProperty(String key, Class targetType, T defaultValue) { - T value = getProperty(key, targetType); - return (value != null ? value : defaultValue); + public void setPlaceholderSuffix(String placeholderSuffix) { + this.placeholderSuffix = placeholderSuffix; + } + + /** + * Specify the separating character between the placeholders replaced by this + * resolver and their associated default value, or {@code null} if no such + * special character should be processed as a value separator. + *

The default is ":". + * @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR + */ + @Override + public void setValueSeparator(String valueSeparator) { + this.valueSeparator = valueSeparator; + } + + /** + * Set whether to throw an exception when encountering an unresolvable placeholder + * nested within the value of a given property. A {@code false} value indicates strict + * resolution, i.e. that an exception will be thrown. A {@code true} value indicates + * that unresolvable nested placeholders should be passed through in their unresolved + * ${...} form. + *

The default is {@code false}. + * @since 3.2 + */ + @Override + public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) { + this.ignoreUnresolvableNestedPlaceholders = ignoreUnresolvableNestedPlaceholders; } @Override @@ -97,6 +131,19 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe } } + + @Override + public String getProperty(String key, String defaultValue) { + String value = getProperty(key); + return (value != null ? value : defaultValue); + } + + @Override + public T getProperty(String key, Class targetType, T defaultValue) { + T value = getProperty(key, targetType); + return (value != null ? value : defaultValue); + } + @Override public String getRequiredProperty(String key) throws IllegalStateException { String value = getProperty(key); @@ -115,33 +162,6 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe return value; } - /** - * {@inheritDoc} The default is "${". - * @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_PREFIX - */ - @Override - public void setPlaceholderPrefix(String placeholderPrefix) { - this.placeholderPrefix = placeholderPrefix; - } - - /** - * {@inheritDoc} The default is "}". - * @see org.springframework.util.SystemPropertyUtils#PLACEHOLDER_SUFFIX - */ - @Override - public void setPlaceholderSuffix(String placeholderSuffix) { - this.placeholderSuffix = placeholderSuffix; - } - - /** - * {@inheritDoc} The default is ":". - * @see org.springframework.util.SystemPropertyUtils#VALUE_SEPARATOR - */ - @Override - public void setValueSeparator(String valueSeparator) { - this.valueSeparator = valueSeparator; - } - @Override public String resolvePlaceholders(String text) { if (this.nonStrictHelper == null) { @@ -158,16 +178,6 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe return doResolvePlaceholders(text, this.strictHelper); } - /** - * {@inheritDoc} - *

The default value for this implementation is {@code false}. - * @since 3.2 - */ - @Override - public void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) { - this.ignoreUnresolvableNestedPlaceholders = ignoreUnresolvableNestedPlaceholders; - } - /** * Resolve placeholders within the given string, deferring to the value of * {@link #setIgnoreUnresolvableNestedPlaceholders} to determine whether any @@ -199,6 +209,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe }); } + /** * Retrieve the specified property as a raw String, * i.e. without resolution of nested placeholders. diff --git a/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java index eceaff8057b..c71630fdbb8 100644 --- a/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java @@ -223,8 +223,7 @@ public abstract class CommandLinePropertySource extends EnumerablePropertySou } /** - * Return whether this {@code PropertySource} contains a property with the given name. - *

This implementation first checks to see if the name specified is the special + * This implementation first checks to see if the name specified is the special * {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property}, * and if so delegates to the abstract {@link #getNonOptionArgs()} method * checking to see whether it returns an empty collection. Otherwise delegates to and @@ -239,8 +238,7 @@ public abstract class CommandLinePropertySource extends EnumerablePropertySou } /** - * {@inheritDoc} - *

This implementation first checks to see if the name specified is the special + * This implementation first checks to see if the name specified is the special * {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property}, * and if so delegates to the abstract {@link #getNonOptionArgs()} method. If so * and the collection of non-option arguments is empty, this method returns {@code diff --git a/spring-core/src/main/java/org/springframework/core/env/ConfigurablePropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/ConfigurablePropertyResolver.java index 823ae438636..e1ec8a2732d 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ConfigurablePropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/ConfigurablePropertyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -73,6 +73,19 @@ public interface ConfigurablePropertyResolver extends PropertyResolver { */ void setValueSeparator(String valueSeparator); + /** + * Set whether to throw an exception when encountering an unresolvable placeholder + * nested within the value of a given property. A {@code false} value indicates strict + * resolution, i.e. that an exception will be thrown. A {@code true} value indicates + * that unresolvable nested placeholders should be passed through in their unresolved + * ${...} form. + *

Implementations of {@link #getProperty(String)} and its variants must inspect + * the value set here to determine correct behavior when property values contain + * unresolvable placeholders. + * @since 3.2 + */ + void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders); + /** * Specify which properties must be present, to be verified by * {@link #validateRequiredProperties()}. @@ -88,16 +101,4 @@ public interface ConfigurablePropertyResolver extends PropertyResolver { */ void validateRequiredProperties() throws MissingRequiredPropertiesException; - /** - * Set whether to throw an exception when encountering an unresolvable placeholder - * nested within the value of a given property. A {@code false} value indicates strict - * resolution, i.e. that an exception will be thrown. A {@code true} value indicates - * that unresolvable nested placeholders should be passed through in their unresolved - * ${...} form. - *

Implementations of {@link #getProperty(String)} and its variants must inspect - * the value set here to determine correct behavior when property values contain - * unresolvable placeholders. - * @since 3.2 - */ - void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders); } diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java index 2e242c61fd6..2c48c2507fb 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -17,7 +17,6 @@ package org.springframework.mock.jndi; import java.util.Hashtable; - import javax.naming.Context; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; @@ -196,7 +195,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder if (activated == null && environment != null) { Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY); if (icf != null) { - Class icfClass = null; + Class icfClass; if (icf instanceof Class) { icfClass = (Class) icf; } @@ -215,10 +214,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder return (InitialContextFactory) icfClass.newInstance(); } catch (Throwable ex) { - IllegalStateException ise = - new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf); - ise.initCause(ex); - throw ise; + throw new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf, ex); } } }