diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 1d65384d4a..91db94e3f1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -961,7 +961,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto for (String beanName : beanNames) { Object singletonInstance = getSingleton(beanName); if (singletonInstance instanceof SmartInitializingSingleton) { - StartupStep smartInitialize = this.getApplicationStartup().start("spring.beans.smart-initialize") + StartupStep smartInitialize = getApplicationStartup().start("spring.beans.smart-initialize") .tag("beanName", beanName); SmartInitializingSingleton smartSingleton = (SmartInitializingSingleton) singletonInstance; if (System.getSecurityManager() != null) { diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java index a269d5a81b..f0ff23bfb0 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 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. @@ -64,9 +64,10 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor /** - * Specify the maximum time allotted in milliseconds for the shutdown of - * any phase (group of SmartLifecycle beans with the same 'phase' value). - *
The default value is 30 seconds. + * Specify the maximum time allotted in milliseconds for the shutdown of any + * phase (group of {@link SmartLifecycle} beans with the same 'phase' value). + *
The default value is 30000 milliseconds (30 seconds). + * @see SmartLifecycle#getPhase() */ public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) { this.timeoutPerShutdownPhase = timeoutPerShutdownPhase; diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java index 91ef6b62ff..5200edc054 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java @@ -108,9 +108,9 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** * Set whether to wait for scheduled tasks to complete on shutdown, * not interrupting running tasks and executing all tasks in the queue. - *
Default is "false", shutting down immediately through interrupting - * ongoing tasks and clearing the queue. Switch this flag to "true" if you - * prefer fully completed tasks at the expense of a longer shutdown phase. + *
Default is {@code false}, shutting down immediately through interrupting + * ongoing tasks and clearing the queue. Switch this flag to {@code true} if + * you prefer fully completed tasks at the expense of a longer shutdown phase. *
Note that Spring's container shutdown continues while ongoing tasks * are being completed. If you want this executor to block and wait for the * termination of tasks before the rest of the container continues to shut @@ -211,9 +211,13 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac } /** - * Perform a shutdown on the underlying ExecutorService. + * Perform a full shutdown on the underlying ExecutorService, + * according to the corresponding configuration settings. + * @see #setWaitForTasksToCompleteOnShutdown + * @see #setAwaitTerminationMillis * @see java.util.concurrent.ExecutorService#shutdown() * @see java.util.concurrent.ExecutorService#shutdownNow() + * @see java.util.concurrent.ExecutorService#awaitTermination */ public void shutdown() { if (logger.isDebugEnabled()) { diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java index e60333950f..04ba84eedd 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -95,9 +95,8 @@ public class EnableAsyncTests { public void properExceptionForExistingProxyDependencyMismatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class, AsyncBeanWithInterface.class, AsyncBeanUser.class); - assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy( - ctx::refresh) - .withCauseInstanceOf(BeanNotOfRequiredTypeException.class); + assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh) + .withCauseInstanceOf(BeanNotOfRequiredTypeException.class); ctx.close(); } @@ -105,9 +104,8 @@ public class EnableAsyncTests { public void properExceptionForResolvedProxyDependencyMismatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class, AsyncBeanUser.class, AsyncBeanWithInterface.class); - assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy( - ctx::refresh) - .withCauseInstanceOf(BeanNotOfRequiredTypeException.class); + assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh) + .withCauseInstanceOf(BeanNotOfRequiredTypeException.class); ctx.close(); } @@ -182,8 +180,7 @@ public class EnableAsyncTests { @SuppressWarnings("resource") AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AspectJAsyncAnnotationConfig.class); - assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy( - ctx::refresh); + assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(ctx::refresh); } @Test diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index 28bdafd59f..25f59ac8bd 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 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. @@ -61,7 +61,7 @@ public class EnableSchedulingTests { @EnabledForTestGroups(LONG_RUNNING) public void withFixedRateTask() throws InterruptedException { ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfig.class); - assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(2); + assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks()).hasSize(2); Thread.sleep(100); assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10); @@ -71,7 +71,7 @@ public class EnableSchedulingTests { @EnabledForTestGroups(LONG_RUNNING) public void withSubclass() throws InterruptedException { ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfigSubclass.class); - assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(2); + assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks()).hasSize(2); Thread.sleep(100); assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10); @@ -81,13 +81,13 @@ public class EnableSchedulingTests { @EnabledForTestGroups(LONG_RUNNING) public void withExplicitScheduler() throws InterruptedException { ctx = new AnnotationConfigApplicationContext(ExplicitSchedulerConfig.class); - assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(1); + assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks()).hasSize(1); Thread.sleep(100); assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10); assertThat(ctx.getBean(ExplicitSchedulerConfig.class).threadName).startsWith("explicitScheduler-"); assertThat(Arrays.asList(ctx.getDefaultListableBeanFactory().getDependentBeans("myTaskScheduler")).contains( - TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)).isTrue(); + TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)).isTrue(); } @Test @@ -100,7 +100,7 @@ public class EnableSchedulingTests { @EnabledForTestGroups(LONG_RUNNING) public void withExplicitScheduledTaskRegistrar() throws InterruptedException { ctx = new AnnotationConfigApplicationContext(ExplicitScheduledTaskRegistrarConfig.class); - assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(1); + assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks()).hasSize(1); Thread.sleep(100); assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThanOrEqualTo(10); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java index a9061e162f..0be44d55b7 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java @@ -125,18 +125,19 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess } /** - * Specify the phase in which this container should be started and - * stopped. The startup order proceeds from lowest to highest, and - * the shutdown order is the reverse of that. By default this value - * is Integer.MAX_VALUE meaning that this container starts as late - * as possible and stops as soon as possible. + * Specify the lifecycle phase in which this container should be started and stopped. + *
The startup order proceeds from lowest to highest, and the shutdown order + * is the reverse of that. The default is {@link #DEFAULT_PHASE} meaning that + * this container starts as late as possible and stops as soon as possible. + * @see SmartLifecycle#getPhase() */ public void setPhase(int phase) { this.phase = phase; } /** - * Return the phase in which this container will be started and stopped. + * Return the lifecycle phase in which this container will be started and stopped. + * @see #setPhase */ @Override public int getPhase() {