Closes gh-14517
This commit is contained in:
Johnny Lim 2018-09-20 02:47:56 +09:00 committed by Stephane Nicoll
parent efae363974
commit 521f746151
11 changed files with 30 additions and 33 deletions

View File

@ -254,7 +254,6 @@ public class QuartzAutoConfigurationTests {
"spring.quartz.scheduler-name=testScheduler",
"spring.quartz.auto-startup=false", "spring.quartz.startup-delay=1m",
"spring.quartz.wait-for-jobs-to-complete-on-shutdown=true",
"spring.quartz.wait-for-jobs-to-complete-on-shutdown=true",
"spring.quartz.overwrite-existing-jobs=true").run((context) -> {
assertThat(context).hasSingleBean(SchedulerFactoryBean.class);
SchedulerFactoryBean schedulerFactory = context

View File

@ -36,6 +36,7 @@ content into your application. Rather, pick only the properties that you need.
logging.file= # Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory.
logging.file.max-history=0 # Maximum of archive log files to keep. Only supported with the default logback setup.
logging.file.max-size=10MB # Maximum log file size. Only supported with the default logback setup.
logging.group.*= # Log groups to quickly change multiple loggers at the same time. For instance, `logging.level.db=org.hibernate,org.springframework.jdbc`.
logging.level.*= # Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`.
logging.path= # Location of the log file. For instance, `/var/log`.
logging.pattern.console= # Appender pattern for output to the console. Supported only with the default Logback setup.
@ -147,10 +148,10 @@ content into your application. Rather, pick only the properties that you need.
spring.quartz.jdbc.initialize-schema=embedded # Database schema initialization mode.
spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.quartz.job-store-type=memory # Quartz job store type.
spring.quartz.overwrite-existing-jobs=false # Whether configured jobs should overwrite existing job definitions.
spring.quartz.properties.*= # Additional Quartz Scheduler properties.
spring.quartz.scheduler-name=quartzScheduler # Name of the scheduler.
spring.quartz.startup-delay=0s # Delay after which the scheduler is started once initialization completes.
spring.quartz.overwrite-existing-jobs=false # Whether configured jobs should overwrite existing job definitions.
spring.quartz.wait-for-jobs-to-complete-on-shutdown=false # Whether to wait for running jobs to complete on shutdown.
# REACTOR ({sc-spring-boot-autoconfigure}/reactor/core/ReactorCoreProperties.{sc-ext}[ReactorCoreProperties])

View File

@ -1735,11 +1735,11 @@ The following example shows potential logging settings in `application.propertie
=== Log Groups
It's often useful to be able to group related loggers together so that they can all be
configured at the same time. For example, you might commonly change the logging levels for
_all_ Tomcat related loggers, but you can't easily remember to top level packages.
_all_ Tomcat related loggers, but you can't easily remember top level packages.
To help with this, Spring Boot allows you do define logging groups in your Spring
To help with this, Spring Boot allows you to define logging groups in your Spring
`Environment`. For example, here's how you could define a "`tomcat`" group by adding
it to your `appplication.properties`:
it to your `application.properties`:
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----

View File

@ -116,7 +116,7 @@ public class WebTestClientAutoConfigurationTests {
.getField(builder, "httpHandlerBuilder");
List<WebFilter> filters = (List<WebFilter>) ReflectionTestUtils
.getField(httpHandlerBuilder, "filters");
assertThat(filters.size()).isEqualTo(0);
assertThat(filters).isEmpty();
});
}

View File

@ -45,10 +45,11 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
if (isTestServerPortRandom(source)) {
if (source.getProperty(MANAGEMENT_PORT_PROPERTY) == null) {
String managementPort = getPort(environment, MANAGEMENT_PORT_PROPERTY,
String managementPort = getProperty(environment, MANAGEMENT_PORT_PROPERTY,
null);
String serverPort = getPort(environment, SERVER_PORT_PROPERTY, "8080");
if (managementPort != null && !managementPort.equals("-1")) {
String serverPort = getProperty(environment, SERVER_PORT_PROPERTY,
"8080");
if (!managementPort.equals(serverPort)) {
source.getSource().put(MANAGEMENT_PORT_PROPERTY, "0");
}
@ -65,7 +66,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor
return (source != null && "0".equals(source.getProperty(SERVER_PORT_PROPERTY)));
}
private String getPort(ConfigurableEnvironment environment, String property,
private String getProperty(ConfigurableEnvironment environment, String property,
String defaultValue) {
return environment.getPropertySources().stream()
.filter((source) -> !source.getName().equals(

View File

@ -190,7 +190,7 @@ public class MockitoPostProcessorTests {
@Configuration
static class MultipleQualifiedBeans {
@MockBean(ExampleService.class)
@MockBean
@Qualifier("test")
private ExampleService mock;
@ -216,7 +216,7 @@ public class MockitoPostProcessorTests {
@Configuration
static class MockPrimaryBean {
@MockBean(ExampleService.class)
@MockBean
private ExampleService mock;
@Bean
@ -236,7 +236,7 @@ public class MockitoPostProcessorTests {
@Configuration
static class MockQualifiedBean {
@MockBean(ExampleService.class)
@MockBean
@Qualifier("test")
private ExampleService mock;
@ -257,7 +257,7 @@ public class MockitoPostProcessorTests {
@Configuration
static class SpyPrimaryBean {
@SpyBean(ExampleService.class)
@SpyBean
private ExampleService spy;
@Bean
@ -277,7 +277,7 @@ public class MockitoPostProcessorTests {
@Configuration
static class SpyQualifiedBean {
@SpyBean(ExampleService.class)
@SpyBean
@Qualifier("test")
private ExampleService spy;

View File

@ -50,7 +50,6 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
@Test
public void postProcessWhenServerAndManagementPortIsZeroInTestPropertySource() {
addTestPropertySource("0", "0");
this.environment.setProperty("management.server.port", "0");
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
@ -81,8 +80,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
addTestPropertySource("0", null);
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port"))
.isEqualTo(null);
assertThat(this.environment.getProperty("management.server.port")).isNull();
}
@Test
@ -100,7 +98,8 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
@Test
public void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDefaultSameInProduction() {
// mgmt port is 8080 which means its on the same port as main server since that is
// mgmt port is 8080 which means it's on the same port as main server since that
// is
// null in app properties
addTestPropertySource("0", null);
Map<String, Object> other = new HashMap<>();

View File

@ -59,7 +59,7 @@ import org.springframework.util.StringUtils;
* environment contains a {@code logging.config} property it will be used to bootstrap the
* logging system, otherwise a default configuration is used. Regardless, logging levels
* will be customized if the environment contains {@code logging.level.*} entries and
* logging groups can be defined with {@code logging.group} .
* logging groups can be defined with {@code logging.group}.
* <p>
* Debug and trace logging for Spring, Tomcat, Jetty and Hibernate will be enabled when
* the environment contains {@code debug} or {@code trace} properties that aren't set to
@ -150,7 +150,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
private static final Class<?>[] SOURCE_TYPES = { SpringApplication.class,
ApplicationContext.class };
private static AtomicBoolean shutdownHookRegistered = new AtomicBoolean(false);
private static final AtomicBoolean shutdownHookRegistered = new AtomicBoolean(false);
private final Log logger = LogFactory.getLog(getClass());
@ -323,7 +323,8 @@ public class LoggingApplicationListener implements GenericApplicationListener {
return;
}
Binder binder = Binder.get(environment);
Map<String, String[]> groups = getGroups(binder);
Map<String, String[]> groups = getGroups();
binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups));
Map<String, String> levels = binder.bind("logging.level", STRING_STRING_MAP)
.orElseGet(Collections::emptyMap);
levels.forEach((name, level) -> {
@ -337,11 +338,10 @@ public class LoggingApplicationListener implements GenericApplicationListener {
});
}
private Map<String, String[]> getGroups(Binder binder) {
private Map<String, String[]> getGroups() {
Map<String, String[]> groups = new LinkedHashMap<>();
DEFAULT_GROUP_LOGGERS.forEach(
(name, loggers) -> groups.put(name, StringUtils.toStringArray(loggers)));
binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups));
return groups;
}
@ -405,7 +405,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
/**
* Sets if initialization arguments should be parsed for {@literal debug} and
* {@literal trace} properties (usually defined from {@literal --debug} or
* {@literal --trace} command line args. Defaults to {@code true}.
* {@literal --trace} command line args). Defaults to {@code true}.
* @param parseArgs if arguments should be parsed
*/
public void setParseArgs(boolean parseArgs) {

View File

@ -55,7 +55,8 @@ public class ApplicationConversionService extends FormattingConversionService {
/**
* Return a shared default {@code ApplicationConversionService} instance, lazily
* building it once needed.
* @return the shared {@code ConversionService} instance (never {@code null})
* @return the shared {@code ApplicationConversionService} instance (never
* {@code null})
*/
public static ApplicationConversionService getSharedInstance() {
ApplicationConversionService sharedInstance = ApplicationConversionService.sharedInstance;

View File

@ -88,15 +88,15 @@
"defaultValue": 0
},
{
"name": "logging.level",
"name": "logging.group",
"type": "java.util.Map<java.lang.String,java.lang.String>",
"description": "Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`.",
"description": "Log groups to quickly change multiple loggers at the same time. For instance, `logging.level.db=org.hibernate,org.springframework.jdbc`.",
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener"
},
{
"name": "logging.group",
"name": "logging.level",
"type": "java.util.Map<java.lang.String,java.lang.String>",
"description": "Log groups to quickly change multipe loggers at the same time. For instance, `logging.level.db=org.hibernate,org.springframework.jdbc`.",
"description": "Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`.",
"sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener"
},
{

View File

@ -34,8 +34,4 @@ public class HelloWorldService {
return "Hello " + this.name + " for " + this.duration.getSeconds() + " seconds";
}
public Duration getDuration() {
return this.duration;
}
}