For the tracker, it's my private workaround for
HBASE-5666, it should not have been included in this patch. Sorry about this.
I think it's better to delete the file explicitly, just after the znode deletion. HRegionServer#deleteMyEphemeralNode is called only once, and I added deleteMyEphemeralNodeOnDisk just after this call. If we rely on #deleteOnExit, I fear we could have the file deleted with a still alive znode. I'm not sure and I have not tried it, but I think it's too easy to enter into the jvm-specific-behavior space here.
I will fix the java code and try the whole fix on a real cluster for the v2.
Thanks you for the review.