Thanks for the reply. I understand your point regarding exception. I will do the below check.
if (Optional.ofNullable(aliMnsId).isPresent() && aliMnsId.isPresent())
But if you put this “(aliMnsId != null && aliMnsId.isPresent())” then Sonarqube will give error “null” should not be used with "Optional"