Browse Source

Merge pull request #110 from cfritz0127/cleaner-shutdown-on-deregistration-error

* cleaner-shutdown-on-deregistration-error:
  Catch and log exceptions that occur when attempting to deregister a service during shutdown.
pull/123/head
Spencer Gibb 9 years ago
parent
commit
8c9317bd7e
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 16
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java

16
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/AbstractDiscoveryLifecycle.java

@ -16,8 +16,13 @@ @@ -16,8 +16,13 @@
package org.springframework.cloud.client.discovery;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PreDestroy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
@ -26,9 +31,6 @@ import org.springframework.context.ApplicationContextAware; @@ -26,9 +31,6 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.core.env.Environment;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Lifecycle methods that may be useful and common to various DiscoveryClient implementations.
* @author Spencer Gibb
@ -36,6 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger; @@ -36,6 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger;
public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle,
ApplicationContextAware, ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Log logger = LogFactory.getLog(AbstractDiscoveryLifecycle.class);
private boolean autoStartup = true;
private AtomicBoolean running = new AtomicBoolean(false);
@ -74,7 +78,11 @@ public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle, @@ -74,7 +78,11 @@ public abstract class AbstractDiscoveryLifecycle implements DiscoveryLifecycle,
@Override
public void stop(Runnable callback) {
stop();
try {
stop();
} catch (Exception e) {
logger.error("A problem occurred attempting to stop discovery lifecycle", e);
}
callback.run();
}

Loading…
Cancel
Save