Skip to content

shutdownhook can't unregister instances. #1313

@haiyang1985

Description

@haiyang1985

shutdownhook的时候不会执行FailbackRegistry的unregister方法。

首先,FailbackRegistry定义了一个全局的destroyed,默认值是false。
然后,shutdownhook在destroy之前会首先判断一下这个变量的状态,但是canDestroy就会把它置为true。
@OverRide
public void destroy() {
if (!canDestroy()){
return;
}
super.destroy();
try {
retryFuture.cancel(true);
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}

最后,在真正执行unregister的时候,这个destroyed就会变成true被return掉了,导致FailbackRegistry的unregistry并不会被执行。
@OverRide
public void unregister(URL url) {
if (destroyed.get()){
return;
}
super.unregister(url);
...
}

我看这个代码是8月30号修复issue#568的时候加的,这是个bug,还是有其他的考虑吗?还是我缺少配置?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugBugs to being fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions