Fix issues that GroupBy and Sample doesn't call 'unsubscribe' and also NPE when the key is null in GroupBy

Fix #1958
Also use `isEmpty` instead of `size() == 0`. For ConcurrentXXX, size is usually more expensive than isEmpty