Hi i have the following code.
if (SecurityContextHolder.getContext().getAuthentication() != null
                && SecurityContextHolder.getContext().getAuthentication()
                        .getPrincipal() instanceof User)
When I check with pmd it is giving me an warning: No need to check null before instanceof.
Q1.) How do you fix this warning? 
-- if i just do security SecurityContextHolder.getContext().getAuthentication().getPrincipal() and getAuthentication is null than I would get NPE (Null pointer exception). 
 
     
    