STASHDEV-7788 Cherry pick some changes from https://github.com/atlassian/hazelcast/pull/22