Skip to content

Commit 1535f98

Browse files
committed
Polishing
1 parent 94ae933 commit 1535f98

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void afterPropertiesSet() {
168168
*/
169169
public void initialize() {
170170
if (logger.isInfoEnabled()) {
171-
logger.info("Initializing ExecutorService " + (this.beanName != null ? " '" + this.beanName + "'" : ""));
171+
logger.info("Initializing ExecutorService" + (this.beanName != null ? " '" + this.beanName + "'" : ""));
172172
}
173173
if (!this.threadNamePrefixSet && this.beanName != null) {
174174
setThreadNamePrefix(this.beanName + "-");

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,21 @@ public MutablePropertySources getPropertySources() {
380380

381381
@Override
382382
@SuppressWarnings({"unchecked", "rawtypes"})
383-
public Map<String, Object> getSystemEnvironment() {
384-
if (suppressGetenvAccess()) {
385-
return Collections.emptyMap();
386-
}
383+
public Map<String, Object> getSystemProperties() {
387384
try {
388-
return (Map) System.getenv();
385+
return (Map) System.getProperties();
389386
}
390387
catch (AccessControlException ex) {
391388
return (Map) new ReadOnlySystemAttributesMap() {
392389
@Override
393390
@Nullable
394391
protected String getSystemAttribute(String attributeName) {
395392
try {
396-
return System.getenv(attributeName);
393+
return System.getProperty(attributeName);
397394
}
398395
catch (AccessControlException ex) {
399396
if (logger.isInfoEnabled()) {
400-
logger.info("Caught AccessControlException when accessing system environment variable '" +
397+
logger.info("Caught AccessControlException when accessing system property '" +
401398
attributeName + "'; its value will be returned [null]. Reason: " + ex.getMessage());
402399
}
403400
return null;
@@ -407,38 +404,26 @@ protected String getSystemAttribute(String attributeName) {
407404
}
408405
}
409406

410-
/**
411-
* Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)}
412-
* access for the purposes of {@link #getSystemEnvironment()}.
413-
* <p>If this method returns {@code true}, an empty dummy Map will be used instead
414-
* of the regular system environment Map, never even trying to call {@code getenv}
415-
* and therefore avoiding security manager warnings (if any).
416-
* <p>The default implementation checks for the "spring.getenv.ignore" system property,
417-
* returning {@code true} if its value equals "true" in any case.
418-
* @see #IGNORE_GETENV_PROPERTY_NAME
419-
* @see SpringProperties#getFlag
420-
*/
421-
protected boolean suppressGetenvAccess() {
422-
return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME);
423-
}
424-
425407
@Override
426408
@SuppressWarnings({"unchecked", "rawtypes"})
427-
public Map<String, Object> getSystemProperties() {
409+
public Map<String, Object> getSystemEnvironment() {
410+
if (suppressGetenvAccess()) {
411+
return Collections.emptyMap();
412+
}
428413
try {
429-
return (Map) System.getProperties();
414+
return (Map) System.getenv();
430415
}
431416
catch (AccessControlException ex) {
432417
return (Map) new ReadOnlySystemAttributesMap() {
433418
@Override
434419
@Nullable
435420
protected String getSystemAttribute(String attributeName) {
436421
try {
437-
return System.getProperty(attributeName);
422+
return System.getenv(attributeName);
438423
}
439424
catch (AccessControlException ex) {
440425
if (logger.isInfoEnabled()) {
441-
logger.info("Caught AccessControlException when accessing system property '" +
426+
logger.info("Caught AccessControlException when accessing system environment variable '" +
442427
attributeName + "'; its value will be returned [null]. Reason: " + ex.getMessage());
443428
}
444429
return null;
@@ -448,6 +433,21 @@ protected String getSystemAttribute(String attributeName) {
448433
}
449434
}
450435

436+
/**
437+
* Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)}
438+
* access for the purposes of {@link #getSystemEnvironment()}.
439+
* <p>If this method returns {@code true}, an empty dummy Map will be used instead
440+
* of the regular system environment Map, never even trying to call {@code getenv}
441+
* and therefore avoiding security manager warnings (if any).
442+
* <p>The default implementation checks for the "spring.getenv.ignore" system property,
443+
* returning {@code true} if its value equals "true" in any case.
444+
* @see #IGNORE_GETENV_PROPERTY_NAME
445+
* @see SpringProperties#getFlag
446+
*/
447+
protected boolean suppressGetenvAccess() {
448+
return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME);
449+
}
450+
451451
@Override
452452
public void merge(ConfigurableEnvironment parent) {
453453
for (PropertySource<?> ps : parent.getPropertySources()) {

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -37,7 +37,7 @@
3737
* <pre class="code">
3838
* ConfigurableEnvironment environment = new StandardEnvironment();
3939
* MutablePropertySources propertySources = environment.getPropertySources();
40-
* Map<String, String> myMap = new HashMap<String, String>();
40+
* Map&lt;String, String&gt; myMap = new HashMap&lt;&gt;();
4141
* myMap.put("xyz", "myValue");
4242
* propertySources.addFirst(new MapPropertySource("MY_MAP", myMap));
4343
* </pre>
@@ -78,26 +78,26 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
7878
* <p>Any existing active profiles will be replaced with the given arguments; call
7979
* with zero arguments to clear the current set of active profiles. Use
8080
* {@link #addActiveProfile} to add a profile while preserving the existing set.
81+
* @throws IllegalArgumentException if any profile is null, empty or whitespace-only
8182
* @see #addActiveProfile
8283
* @see #setDefaultProfiles
8384
* @see org.springframework.context.annotation.Profile
8485
* @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
85-
* @throws IllegalArgumentException if any profile is null, empty or whitespace-only
8686
*/
8787
void setActiveProfiles(String... profiles);
8888

8989
/**
9090
* Add a profile to the current set of active profiles.
91-
* @see #setActiveProfiles
9291
* @throws IllegalArgumentException if the profile is null, empty or whitespace-only
92+
* @see #setActiveProfiles
9393
*/
9494
void addActiveProfile(String profile);
9595

9696
/**
9797
* Specify the set of profiles to be made active by default if no other profiles
9898
* are explicitly made active through {@link #setActiveProfiles}.
99-
* @see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
10099
* @throws IllegalArgumentException if any profile is null, empty or whitespace-only
100+
* @see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
101101
*/
102102
void setDefaultProfiles(String... profiles);
103103

@@ -119,34 +119,34 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
119119
MutablePropertySources getPropertySources();
120120

121121
/**
122-
* Return the value of {@link System#getenv()} if allowed by the current
122+
* Return the value of {@link System#getProperties()} if allowed by the current
123123
* {@link SecurityManager}, otherwise return a map implementation that will attempt
124-
* to access individual keys using calls to {@link System#getenv(String)}.
125-
* <p>Note that most {@link Environment} implementations will include this system
126-
* environment map as a default {@link PropertySource} to be searched. Therefore, it
127-
* is recommended that this method not be used directly unless bypassing other
128-
* property sources is expressly intended.
124+
* to access individual keys using calls to {@link System#getProperty(String)}.
125+
* <p>Note that most {@code Environment} implementations will include this system
126+
* properties map as a default {@link PropertySource} to be searched. Therefore, it is
127+
* recommended that this method not be used directly unless bypassing other property
128+
* sources is expressly intended.
129129
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
130130
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
131131
* to a property, {@code null} will be returned and an INFO-level log message will be
132132
* issued noting the exception.
133133
*/
134-
Map<String, Object> getSystemEnvironment();
134+
Map<String, Object> getSystemProperties();
135135

136136
/**
137-
* Return the value of {@link System#getProperties()} if allowed by the current
137+
* Return the value of {@link System#getenv()} if allowed by the current
138138
* {@link SecurityManager}, otherwise return a map implementation that will attempt
139-
* to access individual keys using calls to {@link System#getProperty(String)}.
140-
* <p>Note that most {@code Environment} implementations will include this system
141-
* properties map as a default {@link PropertySource} to be searched. Therefore, it is
142-
* recommended that this method not be used directly unless bypassing other property
143-
* sources is expressly intended.
139+
* to access individual keys using calls to {@link System#getenv(String)}.
140+
* <p>Note that most {@link Environment} implementations will include this system
141+
* environment map as a default {@link PropertySource} to be searched. Therefore, it
142+
* is recommended that this method not be used directly unless bypassing other
143+
* property sources is expressly intended.
144144
* <p>Calls to {@link Map#get(Object)} on the Map returned will never throw
145145
* {@link IllegalAccessException}; in cases where the SecurityManager forbids access
146146
* to a property, {@code null} will be returned and an INFO-level log message will be
147147
* issued noting the exception.
148148
*/
149-
Map<String, Object> getSystemProperties();
149+
Map<String, Object> getSystemEnvironment();
150150

151151
/**
152152
* Append the given parent environment's active profiles, default profiles and

0 commit comments

Comments
 (0)