Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic occurs if io.Closer is an unhashable type. #18

Closed
lcaballero opened this issue Mar 5, 2016 · 1 comment
Closed

Panic occurs if io.Closer is an unhashable type. #18

lcaballero opened this issue Mar 5, 2016 · 1 comment

Comments

@lcaballero
Copy link
Contributor

This explains what is allowed as a key in a map.

The language spec defines this precisely, but in short, comparable types are boolean, numeric, string, pointer, channel, and interface types, and structs or arrays that contain only those types.

Below is a test for the issue I'm describing:

type Unhashable map[string]interface{}
func (u Unhashable) Close() error {
    return nil
}

Convey("Validate death happens cleanly", t, func() {
    u := make(Unhashable)
    death := NewDeath(syscall.SIGTERM)
    syscall.Kill(os.Getpid(), syscall.SIGTERM)
    death.WaitForDeath(u)
})

At the moment death will panic because Unhashable is, well, unhashable, but also an io.Closer. See my suggested solution #17

In summary, it just uses the index of the io.Closer from the internal list of closers. My changes save that index in the closer{} to properly remove from the tracking map.

@vrecan
Copy link
Owner

vrecan commented Mar 5, 2016

#17 fixes this

@vrecan vrecan closed this as completed Mar 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants