title: Spring Security getprincipal() method returns string (Username) in place of class UserDetails
body: <p>We are using Spring-boot 2.0.5 with JWT Token</p>
  
  <p><code>SecurityContextHolder.getContext().getAuthentication().getPrincipal()</code>   returning <code>String (Username)</code> in place of <code>CustomUserDetails</code> Object which is implemented <code>UserDetails</code> class  in WAR file only.</p>
  
  <p>This issue only replicates occasionally  most of the time the code is working perfectly</p>
  
  <p>The below mention is the only custom filter we are using and it is called after FilterSecurityInterceptor Filter</p>
  
  <pre><code>public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
          throws IOException, ServletException {
      CustomHttpServletRequestWrapper request = new CustomHttpServletRequestWrapper((HttpServletRequest) req);
      if(request!=null &amp;&amp; request.getHeader("Authorization")!=null &amp;&amp; request.getHeader("Authorization").length()&gt;7) {
  
          CustomUserDetails user = (CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  }
  }
  </code></pre>
  
  <p>It should be returning user detail object</p>