Source:
<code>public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { if(username.indexOf(GithubOAuthGroupDetails.ORG_TEAM_SEPARATOR) >= 0 ) { throw new UsernameNotFoundException("Using org*team format instead of username: " + username); } User localUser = User.getById(username, false); Authentication token = SecurityContextHolder.getContext().getAuthentication(); <START> if (token == null || username != token.getPrincipal()) { <END> if(localUser != null && GithubSecretStorage.contains(localUser)){ String accessToken = GithubSecretStorage.retrieve(localUser); try { token = new GithubAuthenticationToken(accessToken, getGithubApiUri()); } catch (IOException e) { throw new UserMayOrMayNotExistException("Could not connect to GitHub API server, target URL = " + getGithubApiUri(), e); } SecurityContextHolder.getContext().setAuthentication(token); }else{ throw new UserMayOrMayNotExistException("Could not get auth token."); } } GithubAuthenticationToken authToken; if (token instanceof GithubAuthenticationToken) { authToken = (GithubAuthenticationToken) token; } else { throw new UserMayOrMayNotExistException("Unexpected authentication type: " + token); } if (localUser != null) { return new GithubOAuthUserDetails(username, authToken); } try { GithubOAuthUserDetails userDetails = authToken.getUserDetails(username); if (userDetails == null) throw new UsernameNotFoundException("Unknown user: " + username); GHOrganization ghOrg = authToken.loadOrganization(username); if (ghOrg != null) { throw new UsernameNotFoundException("user(" + username + ") is also an organization"); } return userDetails; } catch (IOException | Error e) { throw new DataRetrievalFailureException("loadUserByUsername (username=" + username +")", e); } }</code><technical_language>suggestion if (token == null || !username.equals(token.getPrincipal())) { String reference comparison problematic. Edit: root of build failure, due FindBugs discovered problem</technical_language>

Target:
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { if(username.indexOf(GithubOAuthGroupDetails.ORG_TEAM_SEPARATOR) >= 0 ) { throw new UsernameNotFoundException("Using org*team format instead of username: " + username); } User localUser = User.getById(username, false); Authentication token = SecurityContextHolder.getContext().getAuthentication(); if (token == null || !username.equals(token.getPrincipal())) { if(localUser != null && GithubSecretStorage.contains(localUser)){ String accessToken = GithubSecretStorage.retrieve(localUser); try { token = new GithubAuthenticationToken(accessToken, getGithubApiUri()); } catch (IOException e) { throw new UserMayOrMayNotExistException("Could not connect to GitHub API server, target URL = " + getGithubApiUri(), e); } SecurityContextHolder.getContext().setAuthentication(token); }else{ throw new UserMayOrMayNotExistException("Could not get auth token."); } } GithubAuthenticationToken authToken; if (token instanceof GithubAuthenticationToken) { authToken = (GithubAuthenticationToken) token; } else { throw new UserMayOrMayNotExistException("Unexpected authentication type: " + token); } if (localUser != null) { return new GithubOAuthUserDetails(username, authToken); } try { GithubOAuthUserDetails userDetails = authToken.getUserDetails(username); if (userDetails == null) throw new UsernameNotFoundException("Unknown user: " + username); GHOrganization ghOrg = authToken.loadOrganization(username); if (ghOrg != null) { throw new UsernameNotFoundException("user(" + username + ") is also an organization"); } return userDetails; } catch (IOException | Error e) { throw new DataRetrievalFailureException("loadUserByUsername (username=" + username +")", e); } }