Skip to content

shutdownhook can't unregister instances. #1313

Closed

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,还是有其他的考虑吗?还是我缺少配置?

Activity

  1. ralf0131 commented on Feb 2, 2018

    @ralf0131
    Contributor

    Hi, if you think it can be improved, would you mind sending us a pull request?

  2. changed the title [-]shutdownhook无法unregister实例[/-] [+]shutdownhook can't unregister instances.[/+] on Feb 5, 2018
  3. added this to the 2.5.10 milestone on Feb 5, 2018
  4. added a commit that references this issue on Feb 5, 2018
    ce955d5
  5. added 3 commits that reference this issue on Feb 26, 2018
    0d7dfaa
    125e6a1
    a3b8d73
  6. added a commit that references this issue on Sep 9, 2019
    42dbd83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions