eclipse-ee4j / eclipse-ee4j/jersey

Client not thread safe with ApacheConnectorProvider

Open
#3,308 6 comments 0 reactions 0 assignees View on GitHub
Component: connectors Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Executing simple GET requests on a target which requires authentication (BASIC in my case) on more than one thread and the process quickly hangs.

```
@Test public void get() throws Exception
{
// Works as expected if only a single thread is used ExecutorService service = Executors.newFixedThreadPool(2);
try
{
ArrayList> futures = new ArrayList<>();
for (int i=0; i<10; i++)
{
futures.add(service.submit(new GetTask()));
}
for (Future future: futures)
{
System.out.println(future.get(5, TimeUnit.SECONDS));
}
}
finally
{
service.shutdown();
}
}

private class GetTask implements Callable
{
public String call() throws Exception
{
return client.target("https://optrakbi.optrak.com/filestore/readme.txt").request().buildGet().invoke(String.class); }
}
```
#### Environment
Ubuntu 15.04, Oracle JDK 8
#### Affected Versions
[2.22.1]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.