Skip to content

Commit

Permalink
JENKINS-30333 - Using site.getSession() instead of site.createSession()
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Antoniuk committed Sep 9, 2015
1 parent 0322951 commit 00e439d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
Expand Up @@ -263,7 +263,7 @@ private JiraSession getJiraSession(AbstractBuild<?, ?> build) throws IOException
throw new IllegalStateException("JIRA site needs to be configured in the project " + build.getFullDisplayName());
}

JiraSession session = site.createSession();
JiraSession session = site.getSession();
if (session == null) {
throw new IllegalStateException("Remote access for JIRA isn't configured in Jenkins");
}
Expand Down
Expand Up @@ -34,7 +34,7 @@ public String findMailAddressFor(User u) {

for (JiraSite site : JiraProjectProperty.DESCRIPTOR.getSites()) {
try {
JiraSession session = site.createSession();
JiraSession session = site.getSession();
if (session != null) {
com.atlassian.jira.rest.client.api.domain.User user = session.service.getUser(username);
if (user != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/jira/JiraSite.java
Expand Up @@ -226,7 +226,7 @@ public JiraSession getSession() throws IOException {
* @deprecated please use {@link #getSession()} unless you really want a NEW session
*/
@Deprecated
public JiraSession createSession() throws IOException {
private JiraSession createSession() throws IOException {
if (userName == null || password == null)
return null; // remote access not supported

Expand Down
15 changes: 4 additions & 11 deletions src/main/java/hudson/plugins/jira/Updater.java
@@ -1,25 +1,19 @@
package hudson.plugins.jira;

import com.atlassian.jira.rest.client.api.RestClientException;
import com.google.common.base.Joiner;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.*;
import hudson.model.AbstractBuild.DependencyChange;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.Result;
import hudson.model.Run;
import hudson.plugins.jira.listissuesparameter.JiraIssueParameterValue;
import hudson.scm.ChangeLogSet.AffectedFile;
import hudson.scm.ChangeLogSet.Entry;
import hudson.scm.RepositoryBrowser;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -28,7 +22,6 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;

import static java.lang.String.format;

Expand Down Expand Up @@ -67,7 +60,7 @@ static boolean perform(AbstractBuild<?, ?> build, BuildListener listener) {

JiraSession session = null;
try {
session = site.createSession();
session = site.getSession();
} catch (IOException e) {
listener.getLogger().println(Messages.Updater_FailedToConnect());
e.printStackTrace(listener.getLogger());
Expand Down
Expand Up @@ -69,7 +69,7 @@ public List<JiraIssueParameterDefinition.Result> getIssues() throws IOException
if (site == null)
throw new IllegalStateException("JIRA site needs to be configured in the project " + context.getFullDisplayName());

JiraSession session = site.createSession();
JiraSession session = site.getSession();
if (session == null) throw new IllegalStateException("Remote access for JIRA isn't configured in Jenkins");

List<Issue> issues = session.getIssuesFromJqlSearch(jiraIssueFilter);
Expand Down
Expand Up @@ -9,7 +9,6 @@
import hudson.plugins.jira.JiraSession;
import hudson.plugins.jira.JiraSite;
import net.sf.json.JSONObject;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
Expand Down Expand Up @@ -66,7 +65,7 @@ public List<JiraVersionParameterDefinition.Result> getVersions() throws IOExcept
if (site == null)
throw new IllegalStateException("JIRA site needs to be configured in the project " + context.getFullDisplayName());

JiraSession session = site.createSession();
JiraSession session = site.getSession();
if (session == null) throw new IllegalStateException("Remote access for JIRA isn't configured in Jenkins");

List<Version> versions = session.getVersions(projectKey);
Expand Down

0 comments on commit 00e439d

Please sign in to comment.