@@ -23,7 +23,6 @@
import javax .servlet .ServletException ;
import java .io .IOException ;
import java .io .PrintStream ;
import java .lang .ref .WeakReference ;
import java .net .MalformedURLException ;
import java .net .URI ;
import java .net .URISyntaxException ;
@@ -139,7 +138,7 @@ public class JiraSite extends AbstractDescribableImpl<JiraSite> {
*/
private transient Lock projectUpdateLock = new ReentrantLock ();
private transient ThreadLocal < WeakReference < JiraSession >> jiraSession = new ThreadLocal < WeakReference < JiraSession >>() ;
private transient JiraSession jiraSession = null ;
@ DataBoundConstructor
public JiraSite (URL url , URL alternativeUrl , String userName , String password , boolean supportsWikiStyleComment , boolean recordScmChanges , String userPattern ,
@@ -175,14 +174,13 @@ public JiraSite(URL url, URL alternativeUrl, String userName, String password, b
this .groupVisibility = Util .fixEmpty (groupVisibility );
this .roleVisibility = Util .fixEmpty (roleVisibility );
this .useHTTPAuth = useHTTPAuth ;
this .jiraSession . set ( new WeakReference < JiraSession >( null )) ;
this .jiraSession = null ;
}
protected Object readResolve () {
projectUpdateLock = new ReentrantLock ();
issueCache = makeIssueCache ();
jiraSession = new ThreadLocal <WeakReference <JiraSession >>();
jiraSession .set (new WeakReference <JiraSession >(null ));
jiraSession = null ;
return this ;
}
@@ -203,20 +201,11 @@ public String getName() {
*/
@ Nullable
public JiraSession getSession () throws IOException {
JiraSession session = null ;
WeakReference <JiraSession > weakReference = jiraSession .get ();
if (weakReference != null ) {
session = weakReference .get ();
if (jiraSession == null ) {
jiraSession = createSession ();
}
if (session == null ) {
// TODO: we should check for session timeout, too
// Currently no real problem, as we're using a weak reference for the session, so it will be GC'ed very quickly
session = createSession ();
jiraSession .set (new WeakReference <JiraSession >(session ));
}
return session ;
return jiraSession ;
}
/**
@@ -226,7 +215,7 @@ public JiraSession getSession() throws IOException {
* @deprecated please use {@link #getSession()} unless you really want a NEW session
*/
@ Deprecated
private JiraSession createSession () throws IOException {
private JiraSession createSession () ta17aab4b71e5311082817c1273dbaeb4be63bc7chrows IOException {
if (userName == null || password == null )
return null ; // remote access not supported
@@ -237,6 +226,7 @@ private JiraSession createSession() throws IOException {
LOGGER .warning ("convert URL to URI error: " + e .getMessage ());
throw new RuntimeException ("failed to create JiraSession due to convert URI error" );
}
LOGGER .info ("creating Jira Session: " + uri );
final JiraRestClient jiraRestClient = new AsynchronousJiraRestClientFactory ()
.createWithBasicHttpAuthentication (uri , userName , password );