Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-44489] fixed findbug introduced by 987608a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-el-habib committed Dec 18, 2017
1 parent a36e7e0 commit 6f2f23c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/jenkinsci/plugins/GitLabLogoutAction.java
Expand Up @@ -71,11 +71,10 @@ public String getGitLabURL() {

@Restricted(NoExternalUse.class) // jelly only
public String getGitLabText() {
Jenkins j = Jenkins.getInstance();
assert j != null;
SecurityRealm r = j.getSecurityRealm();
Jenkins jenkins = Jenkins.getInstance();
assert jenkins != null;
SecurityRealm r = jenkins.getSecurityRealm();
if (r instanceof GitLabSecurityRealm) {
GitLabSecurityRealm glsr = (GitLabSecurityRealm) r;
return "GitLab";
}
// only called from the Jelly if the GitLabSecurityRealm is set...
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/org/jenkinsci/plugins/GitLabSecurityRealm.java
Expand Up @@ -223,16 +223,21 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co
}

private void setValue(GitLabSecurityRealm realm, String node, String value) {
if (node.toLowerCase().equals("clientid")) {
realm.setClientID(value);
} else if (node.toLowerCase().equals("clientsecret")) {
realm.setClientSecret(value);
} else if (node.toLowerCase().equals("gitlabweburi")) {
realm.setGitlabWebUri(value);
} else if (node.toLowerCase().equals("gitlabapiuri")) {
realm.setGitlabApiUri(value);
} else {
throw new ConversionException("Invalid node value = " + node);
switch (node.toLowerCase()) {
case "clientid":
realm.setClientID(value);
break;
case "clientsecret":
realm.setClientSecret(value);
break;
case "gitlabweburi":
realm.setGitlabWebUri(value);
break;
case "gitlabapiuri":
realm.setGitlabApiUri(value);
break;
default:
throw new ConversionException("Invalid node value = " + node);
}
}

Expand Down Expand Up @@ -383,8 +388,6 @@ private String extractToken(String content) {
if (node != null) {
return node.asText();
}
} catch (JsonProcessingException e) {
Log.error(e.getMessage(), e);
} catch (IOException e) {
Log.error(e.getMessage(), e);
}
Expand Down

0 comments on commit 6f2f23c

Please sign in to comment.