DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31680>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31680

DefaultHttpParamsFactory.getDefaultParams() is not thread safe

           Summary: DefaultHttpParamsFactory.getDefaultParams() is not
                    thread safe
           Product: HttpClient
           Version: 3.0 Alpha 2
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Commons HttpClient
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The method getDefaultParams() in 
org.apache.commons.httpclient.params.DefaultHttpParamsFactory is not thread 
safe.  In this code:

    public HttpParams getDefaultParams() {
        if (httpParams == null) {
            httpParams = createParams();
        }

        return httpParams;
    }

it is possible that httpParams will be called by one thread which will set 
httpParams, then a second thread may call it and may find httpParams is 
non-null.  However, under both the old (Java Language Spec chapter 17) and 
new Java Memory Models, the second thread won't necessarily see the values 
the first thread has set in the referenced HttpParams object.

The easiest way to fix this for all JVMs and memory models is by declaring 
getDefaultParams() to be synchronized.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to