hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grigori (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPCLIENT-1619) BasicScheme.authenticate(...) is not thread save
Date Thu, 26 Feb 2015 08:44:04 GMT
Grigori created HTTPCLIENT-1619:
-----------------------------------

             Summary: BasicScheme.authenticate(...) is not thread save
                 Key: HTTPCLIENT-1619
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1619
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpAuth
    Affects Versions: 4.3.6, 4.3.5
            Reporter: Grigori


// 1. create one HttpClient with multi thread connection manager:

    HttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(...)

    HttpClient client = HttpClientBuilder.create()
        .setConnectionManager(connManager)
        ...
        .build();

    AuthSchemeBase auth = new BasicScheme();
    AuthCache authCache = new BasicAuthCache();
    authCache.put(host, auth);

    CredentialsProvider provider = ...;

    HttpClientContext context = HttpClientContext.create();
    context.setCredentialsProvider(provider);
    context.setAuthCache(authCache);


// 2. do parallel requests:

    // multi thread:
    public void doGet() {
      ...
      HttpGet get = new HttpGet(requestUrl);
      HttpResponse resp = client.execute(host, get, context);
      ...
    }


In 4.3.5 sometimes got random wrong header: "Authorization: Basic YXZ2dml0aXR...="
In 4.3.6 sometimes got NullPointerException
Because org.apache.http.impl.auth.BasicScheme.authenticate(...) use not thread save base64codec:
   
  org.apache.http.impl.auth.BasicScheme:165

      final byte[] base64password = base64codec.encode(
                EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)));

  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message