Java API: Make sure afterBulk is always called in BulkProcessor

Java API: Make sure afterBulk is always called in BulkProcessor.

Also strenghtened BulkProcessorTests by adding randomizations to existing tests and new tests for concurrent request.

Closes #5038
yea makes sense or we move the beforeBulk before the semaphore which might make more sense since we want to keep the critical section as small as possible?