@@ -0,0 +1,3780 @@
+/*%0A * Copyright 2010 Ning, Inc.%0A *%0A * Ning licenses this file to you under the Apache License, version 2.0%0A * (the %22License%22); you may not use this file except in compliance with the%0A * License.  You may obtain a copy of the License at:%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage com.ning.http.client.async;%0A%0Aimport com.ning.http.client.AsyncHandler;%0Aimport com.ning.http.client.AsyncHttpClient;%0Aimport com.ning.http.client.AsyncHttpClientConfig;%0Aimport com.ning.http.client.HttpResponseBodyPart;%0Aimport com.ning.http.client.HttpResponseHeaders;%0Aimport com.ning.http.client.HttpResponseStatus;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.io.IOException;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.ExecutionException;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.TimeoutException;%0A%0A%0A/**%0A * Simple stress test for exercising the follow redirect.%0A */%0Apublic class FollowingThreadTest extends AbstractBasicTest %7B%0A%0A    private final static int COUNT = 10;%0A%0A    @Test(timeOut = 30 * 1000, groups = %22scalability%22)%0A    public void testFollowRedirect() throws IOException, ExecutionException, TimeoutException, InterruptedException %7B%0A%0A        final CountDownLatch countDown = new CountDownLatch(COUNT);%0A        ExecutorService pool = Executors.newCachedThreadPool();%0A        for (int i = 0; i %3C COUNT; i++) %7B%0A            pool.submit(new Runnable() %7B%0A%0A                private int status;%0A%0A                public void run() %7B%0A                    final CountDownLatch l = new CountDownLatch(1);%0A                    AsyncHttpClient ahc = new AsyncHttpClient(%0A                            new AsyncHttpClientConfig.Builder().setFollowRedirects(true).build());%0A                    try %7B%0A                        ahc.prepareGet(%22http://www.google.com/%22).execute(new AsyncHandler%3CInteger%3E() %7B%0A%0A                            public void onThrowable(Throwable t) %7B%0A                                t.printStackTrace();%0A                            %7D%0A%0A                            public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception %7B%0A                                System.out.println(new String(bodyPart.getBodyPartBytes()));%0A                                return STATE.CONTINUE;%0A                            %7D%0A%0A                            public STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception %7B%0A                                status = responseStatus.getStatusCode();%0A                                System.out.println(responseStatus.getStatusText());%0A                                return STATE.CONTINUE;%0A                            %7D%0A%0A                            public STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception %7B%0A                                return STATE.CONTINUE;%0A                            %7D%0A%0A                            public Integer onCompleted() throws Exception %7B%0A                                l.countDown();%0A                                return status;%0A                            %7D%0A                        %7D);%0A%0A                        l.await();%0A                    %7D catch (Exception e) %7B%0A                        e.printStackTrace();%0A                    %7D finally %7B%0A                        ahc.close();%0A                        countDown.countDown();%0A                    %7D%0A                %7D%0A            %7D);%0A        %7D%0A        countDown.await();%0A    %7D%0A%0A%7D

Add a unit test trying to reproduce the issue related on the mailling list