This fails when I pass in [hook1, NULL, NULL, hook2]. The result array will be [hook1, hook2, null, null] and the onPostReceive method will NPE when it tries to invoke the 3rd element.

Don't try to be cute and filter out the NULL hook.