Skip to content

Commit 5874383

Browse files
committed
Polish
Issue: SPR-9439
1 parent 5327a7a commit 5874383

File tree

5 files changed

+45
-35
lines changed

5 files changed

+45
-35
lines changed

spring-core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,13 +55,14 @@
5555
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
5656
* </pre>
5757
*
58-
* When an {@link Environment} is being used by an ApplicationContext, it is important
59-
* that any such PropertySource manipulations be performed <em>before</em> the context's
60-
* {@link org.springframework.context.support.AbstractApplicationContext#refresh()
61-
* refresh()} method is called. This ensures that all property sources are available
62-
* during the container bootstrap process, including use by
63-
* {@linkplain org.springframework.context.support.PropertySourcesPlaceholderConfigurer
64-
* property placeholder configurers}.
58+
* When an {@link Environment} is being used by an {@code ApplicationContext}, it is
59+
* important that any such {@code PropertySource} manipulations be performed
60+
* <em>before</em> the context's {@link
61+
* org.springframework.context.support.AbstractApplicationContext#refresh() refresh()}
62+
* method is called. This ensures that all property sources are available during the
63+
* container bootstrap process, including use by {@linkplain
64+
* org.springframework.context.support.PropertySourcesPlaceholderConfigurer property
65+
* placeholder configurers}.
6566
*
6667
*
6768
* @author Chris Beams
@@ -78,7 +79,6 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
7879
* <p>Any existing active profiles will be replaced with the given arguments; call
7980
* with zero arguments to clear the current set of active profiles. Use
8081
* {@link #addActiveProfile} to add a profile while preserving the existing set.
81-
*
8282
* @see #addActiveProfile
8383
* @see #setDefaultProfiles
8484
* @see org.springframework.context.annotation.Profile
@@ -123,12 +123,10 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
123123
* Return the value of {@link System#getenv()} if allowed by the current
124124
* {@link SecurityManager}, otherwise return a map implementation that will attempt
125125
* to access individual keys using calls to {@link System#getenv(String)}.
126-
*
127126
* <p>Note that most {@link Environment} implementations will include this system
128127
* environment map as a default {@link PropertySource} to be searched. Therefore, it
129128
* is recommended that this method not be used directly unless bypassing other
130129
* property sources is expressly intended.
131-
*
132130
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
133131
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
134132
* to a property, {@code null} will be returned and an INFO-level log message will be
@@ -140,12 +138,10 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
140138
* Return the value of {@link System#getProperties()} if allowed by the current
141139
* {@link SecurityManager}, otherwise return a map implementation that will attempt
142140
* to access individual keys using calls to {@link System#getProperty(String)}.
143-
*
144141
* <p>Note that most {@code Environment} implementations will include this system
145142
* properties map as a default {@link PropertySource} to be searched. Therefore, it is
146143
* recommended that this method not be used directly unless bypassing other property
147144
* sources is expressly intended.
148-
*
149145
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
150146
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
151147
* to a property, {@code null} will be returned and an INFO-level log message will be

spring-core/src/main/java/org/springframework/util/Assert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of
@@ -335,7 +335,7 @@ public static void isInstanceOf(Class type, Object obj, String message) {
335335
notNull(type, "Type to check against must not be null");
336336
if (!type.isInstance(obj)) {
337337
throw new IllegalArgumentException(message +
338-
"Object of class [" + (obj != null ? obj.getClass().getName() : "null") +
338+
". Object of class [" + (obj != null ? obj.getClass().getName() : "null") +
339339
"] must be an instance of " + type);
340340
}
341341
}

spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,22 +16,6 @@
1616

1717
package org.springframework.core.env;
1818

19-
import static java.lang.String.format;
20-
import static org.hamcrest.CoreMatchers.equalTo;
21-
import static org.hamcrest.CoreMatchers.instanceOf;
22-
import static org.hamcrest.CoreMatchers.is;
23-
import static org.hamcrest.CoreMatchers.not;
24-
import static org.hamcrest.CoreMatchers.notNullValue;
25-
import static org.hamcrest.CoreMatchers.nullValue;
26-
import static org.junit.Assert.assertSame;
27-
import static org.junit.Assert.assertThat;
28-
import static org.junit.Assert.fail;
29-
import static org.junit.matchers.JUnitMatchers.hasItem;
30-
import static org.junit.matchers.JUnitMatchers.hasItems;
31-
import static org.springframework.core.env.AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME;
32-
import static org.springframework.core.env.AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME;
33-
import static org.springframework.core.env.AbstractEnvironment.RESERVED_DEFAULT_PROFILE_NAME;
34-
3519
import java.lang.reflect.Field;
3620
import java.security.AccessControlException;
3721
import java.security.Permission;
@@ -40,8 +24,18 @@
4024
import java.util.Map;
4125

4226
import org.junit.Test;
27+
4328
import org.springframework.mock.env.MockPropertySource;
4429

30+
import static java.lang.String.*;
31+
32+
import static org.hamcrest.CoreMatchers.*;
33+
34+
import static org.junit.Assert.*;
35+
import static org.junit.matchers.JUnitMatchers.*;
36+
37+
import static org.springframework.core.env.AbstractEnvironment.*;
38+
4539
/**
4640
* Unit tests for {@link StandardEnvironment}.
4741
*

spring-webmvc/src/test/java/org/springframework/web/context/AbstractApplicationContextTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1+
/*
2+
* Copyright 2002-2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.web.context;
18+
219
import java.util.Locale;
320

421
import org.springframework.beans.TestBean;
@@ -136,6 +153,7 @@ public void testBeanAutomaticallyHearsEvents() throws Exception {
136153
}
137154

138155

156+
@SuppressWarnings("serial")
139157
public static class MyEvent extends ApplicationEvent {
140158

141159
public MyEvent(Object source) {

spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package org.springframework.web.context;
1818

19-
import static org.hamcrest.CoreMatchers.sameInstance;
20-
import static org.junit.Assert.assertThat;
21-
2219
import java.util.Locale;
2320

2421
import javax.servlet.ServletException;
@@ -36,6 +33,10 @@
3633
import org.springframework.mock.web.MockServletContext;
3734
import org.springframework.web.context.support.XmlWebApplicationContext;
3835

36+
import static org.hamcrest.CoreMatchers.*;
37+
38+
import static org.junit.Assert.*;
39+
3940
/**
4041
* @author Rod Johnson
4142
* @author Juergen Hoeller
@@ -53,6 +54,7 @@ protected ConfigurableApplicationContext createContext() throws Exception {
5354
root.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
5455
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
5556
beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
57+
@SuppressWarnings("unchecked")
5658
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
5759
if (bean instanceof TestBean) {
5860
((TestBean) bean).getFriends().add("myFriend");

0 commit comments

Comments
 (0)