Commit 521f7461 authored by Johnny Lim's avatar Johnny Lim Committed by Stephane Nicoll

Polish

Closes gh-14517
parent efae3639
...@@ -254,7 +254,6 @@ public class QuartzAutoConfigurationTests { ...@@ -254,7 +254,6 @@ public class QuartzAutoConfigurationTests {
"spring.quartz.scheduler-name=testScheduler", "spring.quartz.scheduler-name=testScheduler",
"spring.quartz.auto-startup=false", "spring.quartz.startup-delay=1m", "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.wait-for-jobs-to-complete-on-shutdown=true",
"spring.quartz.overwrite-existing-jobs=true").run((context) -> { "spring.quartz.overwrite-existing-jobs=true").run((context) -> {
assertThat(context).hasSingleBean(SchedulerFactoryBean.class); assertThat(context).hasSingleBean(SchedulerFactoryBean.class);
SchedulerFactoryBean schedulerFactory = context SchedulerFactoryBean schedulerFactory = context
......
...@@ -36,6 +36,7 @@ content into your application. Rather, pick only the properties that you need. ...@@ -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= # 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-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.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.level.*= # Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`.
logging.path= # Location of the log file. For instance, `/var/log`. 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. 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. ...@@ -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.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.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.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.properties.*= # Additional Quartz Scheduler properties.
spring.quartz.scheduler-name=quartzScheduler # Name of the scheduler. 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.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. 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]) # REACTOR ({sc-spring-boot-autoconfigure}/reactor/core/ReactorCoreProperties.{sc-ext}[ReactorCoreProperties])
......
...@@ -1735,11 +1735,11 @@ The following example shows potential logging settings in `application.propertie ...@@ -1735,11 +1735,11 @@ The following example shows potential logging settings in `application.propertie
=== Log Groups === Log Groups
It's often useful to be able to group related loggers together so that they can all be 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 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 `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"] [source,properties,indent=0,subs="verbatim,quotes,attributes"]
---- ----
......
...@@ -116,7 +116,7 @@ public class WebTestClientAutoConfigurationTests { ...@@ -116,7 +116,7 @@ public class WebTestClientAutoConfigurationTests {
.getField(builder, "httpHandlerBuilder"); .getField(builder, "httpHandlerBuilder");
List<WebFilter> filters = (List<WebFilter>) ReflectionTestUtils List<WebFilter> filters = (List<WebFilter>) ReflectionTestUtils
.getField(httpHandlerBuilder, "filters"); .getField(httpHandlerBuilder, "filters");
assertThat(filters.size()).isEqualTo(0); assertThat(filters).isEmpty();
}); });
} }
......
...@@ -45,10 +45,11 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor ...@@ -45,10 +45,11 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME); .get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
if (isTestServerPortRandom(source)) { if (isTestServerPortRandom(source)) {
if (source.getProperty(MANAGEMENT_PORT_PROPERTY) == null) { if (source.getProperty(MANAGEMENT_PORT_PROPERTY) == null) {
String managementPort = getPort(environment, MANAGEMENT_PORT_PROPERTY, String managementPort = getProperty(environment, MANAGEMENT_PORT_PROPERTY,
null); null);
String serverPort = getPort(environment, SERVER_PORT_PROPERTY, "8080");
if (managementPort != null && !managementPort.equals("-1")) { if (managementPort != null && !managementPort.equals("-1")) {
String serverPort = getProperty(environment, SERVER_PORT_PROPERTY,
"8080");
if (!managementPort.equals(serverPort)) { if (!managementPort.equals(serverPort)) {
source.getSource().put(MANAGEMENT_PORT_PROPERTY, "0"); source.getSource().put(MANAGEMENT_PORT_PROPERTY, "0");
} }
...@@ -65,7 +66,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor ...@@ -65,7 +66,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessor
return (source != null && "0".equals(source.getProperty(SERVER_PORT_PROPERTY))); 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) { String defaultValue) {
return environment.getPropertySources().stream() return environment.getPropertySources().stream()
.filter((source) -> !source.getName().equals( .filter((source) -> !source.getName().equals(
......
...@@ -190,7 +190,7 @@ public class MockitoPostProcessorTests { ...@@ -190,7 +190,7 @@ public class MockitoPostProcessorTests {
@Configuration @Configuration
static class MultipleQualifiedBeans { static class MultipleQualifiedBeans {
@MockBean(ExampleService.class) @MockBean
@Qualifier("test") @Qualifier("test")
private ExampleService mock; private ExampleService mock;
...@@ -216,7 +216,7 @@ public class MockitoPostProcessorTests { ...@@ -216,7 +216,7 @@ public class MockitoPostProcessorTests {
@Configuration @Configuration
static class MockPrimaryBean { static class MockPrimaryBean {
@MockBean(ExampleService.class) @MockBean
private ExampleService mock; private ExampleService mock;
@Bean @Bean
...@@ -236,7 +236,7 @@ public class MockitoPostProcessorTests { ...@@ -236,7 +236,7 @@ public class MockitoPostProcessorTests {
@Configuration @Configuration
static class MockQualifiedBean { static class MockQualifiedBean {
@MockBean(ExampleService.class) @MockBean
@Qualifier("test") @Qualifier("test")
private ExampleService mock; private ExampleService mock;
...@@ -257,7 +257,7 @@ public class MockitoPostProcessorTests { ...@@ -257,7 +257,7 @@ public class MockitoPostProcessorTests {
@Configuration @Configuration
static class SpyPrimaryBean { static class SpyPrimaryBean {
@SpyBean(ExampleService.class) @SpyBean
private ExampleService spy; private ExampleService spy;
@Bean @Bean
...@@ -277,7 +277,7 @@ public class MockitoPostProcessorTests { ...@@ -277,7 +277,7 @@ public class MockitoPostProcessorTests {
@Configuration @Configuration
static class SpyQualifiedBean { static class SpyQualifiedBean {
@SpyBean(ExampleService.class) @SpyBean
@Qualifier("test") @Qualifier("test")
private ExampleService spy; private ExampleService spy;
......
...@@ -50,7 +50,6 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests { ...@@ -50,7 +50,6 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
@Test @Test
public void postProcessWhenServerAndManagementPortIsZeroInTestPropertySource() { public void postProcessWhenServerAndManagementPortIsZeroInTestPropertySource() {
addTestPropertySource("0", "0"); addTestPropertySource("0", "0");
this.environment.setProperty("management.server.port", "0");
this.postProcessor.postProcessEnvironment(this.environment, null); this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0"); assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0"); assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
...@@ -81,8 +80,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests { ...@@ -81,8 +80,7 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
addTestPropertySource("0", null); addTestPropertySource("0", null);
this.postProcessor.postProcessEnvironment(this.environment, null); this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0"); assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")) assertThat(this.environment.getProperty("management.server.port")).isNull();
.isEqualTo(null);
} }
@Test @Test
...@@ -100,7 +98,8 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests { ...@@ -100,7 +98,8 @@ public class SpringBootTestRandomPortEnvironmentPostProcessorTests {
@Test @Test
public void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDefaultSameInProduction() { 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 // null in app properties
addTestPropertySource("0", null); addTestPropertySource("0", null);
Map<String, Object> other = new HashMap<>(); Map<String, Object> other = new HashMap<>();
......
...@@ -59,7 +59,7 @@ import org.springframework.util.StringUtils; ...@@ -59,7 +59,7 @@ import org.springframework.util.StringUtils;
* environment contains a {@code logging.config} property it will be used to bootstrap the * 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 * logging system, otherwise a default configuration is used. Regardless, logging levels
* will be customized if the environment contains {@code logging.level.*} entries and * 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> * <p>
* Debug and trace logging for Spring, Tomcat, Jetty and Hibernate will be enabled when * 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 * the environment contains {@code debug} or {@code trace} properties that aren't set to
...@@ -150,7 +150,7 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -150,7 +150,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
private static final Class<?>[] SOURCE_TYPES = { SpringApplication.class, private static final Class<?>[] SOURCE_TYPES = { SpringApplication.class,
ApplicationContext.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()); private final Log logger = LogFactory.getLog(getClass());
...@@ -323,7 +323,8 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -323,7 +323,8 @@ public class LoggingApplicationListener implements GenericApplicationListener {
return; return;
} }
Binder binder = Binder.get(environment); 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) Map<String, String> levels = binder.bind("logging.level", STRING_STRING_MAP)
.orElseGet(Collections::emptyMap); .orElseGet(Collections::emptyMap);
levels.forEach((name, level) -> { levels.forEach((name, level) -> {
...@@ -337,11 +338,10 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -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<>(); Map<String, String[]> groups = new LinkedHashMap<>();
DEFAULT_GROUP_LOGGERS.forEach( DEFAULT_GROUP_LOGGERS.forEach(
(name, loggers) -> groups.put(name, StringUtils.toStringArray(loggers))); (name, loggers) -> groups.put(name, StringUtils.toStringArray(loggers)));
binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups));
return groups; return groups;
} }
...@@ -405,7 +405,7 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -405,7 +405,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
/** /**
* Sets if initialization arguments should be parsed for {@literal debug} and * Sets if initialization arguments should be parsed for {@literal debug} and
* {@literal trace} properties (usually defined from {@literal --debug} or * {@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 * @param parseArgs if arguments should be parsed
*/ */
public void setParseArgs(boolean parseArgs) { public void setParseArgs(boolean parseArgs) {
......
...@@ -55,7 +55,8 @@ public class ApplicationConversionService extends FormattingConversionService { ...@@ -55,7 +55,8 @@ public class ApplicationConversionService extends FormattingConversionService {
/** /**
* Return a shared default {@code ApplicationConversionService} instance, lazily * Return a shared default {@code ApplicationConversionService} instance, lazily
* building it once needed. * 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() { public static ApplicationConversionService getSharedInstance() {
ApplicationConversionService sharedInstance = ApplicationConversionService.sharedInstance; ApplicationConversionService sharedInstance = ApplicationConversionService.sharedInstance;
......
...@@ -88,15 +88,15 @@ ...@@ -88,15 +88,15 @@
"defaultValue": 0 "defaultValue": 0
}, },
{ {
"name": "logging.level", "name": "logging.group",
"type": "java.util.Map<java.lang.String,java.lang.String>", "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" "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener"
}, },
{ {
"name": "logging.group", "name": "logging.level",
"type": "java.util.Map<java.lang.String,java.lang.String>", "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" "sourceType": "org.springframework.boot.context.logging.LoggingApplicationListener"
}, },
{ {
......
...@@ -34,8 +34,4 @@ public class HelloWorldService { ...@@ -34,8 +34,4 @@ public class HelloWorldService {
return "Hello " + this.name + " for " + this.duration.getSeconds() + " seconds"; return "Hello " + this.name + " for " + this.duration.getSeconds() + " seconds";
} }
public Duration getDuration() {
return this.duration;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment