Skip to content

Commit

Permalink
IMConnectionProvider.java: getAuthenticationHolder(): duplicate the s…
Browse files Browse the repository at this point in the history
…anity-check to satisfy spotbugs

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jan 22, 2024
1 parent 4ff7d7d commit e804dfd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/hudson/plugins/im/IMConnectionProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ private void tryReconnect() {

// we need an additional level of indirection to the Authentication entity
// to fix HUDSON-5978 and HUDSON-5233
@SuppressFBWarnings(
value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
justification = "IMConnectionProvider.descriptor is checked in wrapping getAuthenticationHolder()")
public synchronized AuthenticationHolder getAuthenticationHolder() {
if (descriptor == null || descriptor.getHudsonUserName() == null) {
return null;
Expand All @@ -129,6 +126,12 @@ public Authentication getAuthentication() {
return authentication;
}

// New spotbugs UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
// just can't be quiesced, so duplicating the sanity-check here
if (descriptor == null || descriptor.getHudsonUserName() == null) {
return null;

Check warning on line 132 in src/main/java/hudson/plugins/im/IMConnectionProvider.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 131-132 are not covered by tests
}

User u = User.get(descriptor.getHudsonUserName());

return u.impersonate();
Expand Down

0 comments on commit e804dfd

Please sign in to comment.