Semantically that should be a null pointer exception then. You could also check that accountId is not an empty string "accountId.trim().isEmpty()", in that case an IllegalArgumentException would be appropriate.