From e7b77cb2b6c699b759a55cd81b345cca00ec5b64 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 7 Jul 2017 20:50:35 +0200 Subject: [PATCH] Drop legacy DisposableBean declaration on AbstractApplicationContext Issue: SPR-15154 --- .../quartz/QuartzSchedulerLifecycleTests.java | 10 +++++----- .../context/support/AbstractApplicationContext.java | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java index cd0b83d502..27df9a5969 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSchedulerLifecycleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2017 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. @@ -30,25 +30,25 @@ import static org.junit.Assert.*; */ public class QuartzSchedulerLifecycleTests { - @Test // SPR-6354 + @Test // SPR-6354 public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() { AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass()); assertNotNull(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder")); StopWatch sw = new StopWatch(); sw.start("lazyScheduler"); - context.destroy(); + context.close(); sw.stop(); assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500); } - @Test // SPR-6354 + @Test // SPR-6354 public void destroyLazyInitSchedulerWithCustomShutdownOrderDoesNotHang() { AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass()); assertNotNull(context.getBean("lazyInitSchedulerWithCustomShutdownOrder")); StopWatch sw = new StopWatch(); sw.start("lazyScheduler"); - context.destroy(); + context.close(); sw.stop(); assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500); diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 5f448c63ea..76e05a5b45 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -34,7 +34,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.CachedIntrospectionResults; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; @@ -124,7 +123,7 @@ import org.springframework.util.ReflectionUtils; * @see org.springframework.context.MessageSource */ public abstract class AbstractApplicationContext extends DefaultResourceLoader - implements ConfigurableApplicationContext, DisposableBean { + implements ConfigurableApplicationContext { /** * Name of the MessageSource bean in the factory. @@ -940,12 +939,13 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader } /** - * DisposableBean callback for destruction of this instance. + * Callback for destruction of this instance, originally attached + * to a {@code DisposableBean} implementation (not anymore in 5.0). *

The {@link #close()} method is the native way to shut down * an ApplicationContext, which this method simply delegates to. - * @see #close() + * @deprecated as of Spring Framework 5.0, in favor of {@link #close()} */ - @Override + @Deprecated public void destroy() { close(); }