Change the contract of ResourceLeakDetector.open() so that unsampled resources are recycled

- This also fixes the problem introduced while trying to implement #1612 (Allow to disable resource leak detection).
[#1612] No need for volatile as it is not needed to be precise
Merge remote-tracking branch upstream/$:{upbranch}