|
16 | 16 |
|
17 | 17 | package org.springframework.cloud.client.discovery;
|
18 | 18 |
|
| 19 | +import java.util.concurrent.atomic.AtomicBoolean; |
| 20 | +import java.util.concurrent.atomic.AtomicInteger; |
| 21 | + |
19 | 22 | import javax.annotation.PreDestroy;
|
20 | 23 |
|
| 24 | +import org.apache.commons.logging.Log; |
| 25 | +import org.apache.commons.logging.LogFactory; |
21 | 26 | import org.springframework.beans.BeansException;
|
22 | 27 | import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
23 | 28 | import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
|
|
26 | 31 | import org.springframework.context.ApplicationListener;
|
27 | 32 | import org.springframework.core.env.Environment;
|
28 | 33 |
|
29 |
| -import java.util.concurrent.atomic.AtomicBoolean; |
30 |
| -import java.util.concurrent.atomic.AtomicInteger; |
31 |
| - |
32 | 34 | /**
|
33 | 35 | * Lifecycle methods that may be useful and common to various DiscoveryClient implementations.
|
34 | 36 | * @author Spencer Gibb
|
35 | 37 | */
|
36 | 38 | public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle,
|
37 | 39 | ApplicationContextAware, ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
38 | 40 |
|
| 41 | + private static final Log logger = LogFactory.getLog(AbstractDiscoveryLifecycle.class); |
| 42 | + |
39 | 43 | private boolean autoStartup = true;
|
40 | 44 |
|
41 | 45 | private AtomicBoolean running = new AtomicBoolean(false);
|
@@ -74,7 +78,11 @@ public boolean isAutoStartup() {
|
74 | 78 |
|
75 | 79 | @Override
|
76 | 80 | public void stop(Runnable callback) {
|
77 |
| - stop(); |
| 81 | + try { |
| 82 | + stop(); |
| 83 | + } catch (Exception e) { |
| 84 | + logger.error("A problem occurred attempting to stop discovery lifecycle", e); |
| 85 | + } |
78 | 86 | callback.run();
|
79 | 87 | }
|
80 | 88 |
|
|
0 commit comments