Skip to content

Commit 967f684

Browse files
committed
Fix test name
1 parent 5ad43e2 commit 967f684

File tree

8 files changed

+21
-77
lines changed

8 files changed

+21
-77
lines changed

src/main/java/com/ning/http/client/FutureImpl.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/main/java/com/ning/http/client/providers/apache/ApacheResponseFuture.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
package com.ning.http.client.providers.apache;
1414

1515
import com.ning.http.client.AsyncHandler;
16-
import com.ning.http.client.FutureImpl;
1716
import com.ning.http.client.Request;
17+
import com.ning.http.client.listenable.AbstractListenableFuture;
1818
import org.apache.commons.httpclient.HttpMethodBase;
1919

2020
import java.util.concurrent.Callable;
@@ -28,7 +28,7 @@
2828
import java.util.concurrent.atomic.AtomicReference;
2929

3030

31-
public class ApacheResponseFuture<V> implements FutureImpl<V> {
31+
public class ApacheResponseFuture<V> extends AbstractListenableFuture<V> {
3232

3333
private Future<V> innerFuture;
3434
private final AsyncHandler<V> asyncHandler;

src/main/java/com/ning/http/client/providers/jdk/JDKAsyncHttpProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.ning.http.client.AsyncHttpProviderConfig;
1919
import com.ning.http.client.Body;
2020
import com.ning.http.client.FluentCaseInsensitiveStringsMap;
21-
import com.ning.http.client.FutureImpl;
21+
import com.ning.http.client.ListenableFuture;
2222
import com.ning.http.client.HttpResponseBodyPart;
2323
import com.ning.http.client.HttpResponseHeaders;
2424
import com.ning.http.client.HttpResponseStatus;
@@ -115,7 +115,7 @@ private void configure(JDKAsyncHttpProviderConfig config) {
115115
public <T> Future<T> execute(Request request, AsyncHandler<T> handler) throws IOException {
116116
return execute(request, handler, null);
117117
}
118-
public <T> Future<T> execute(Request request, AsyncHandler<T> handler, FutureImpl<?> future) throws IOException {
118+
public <T> Future<T> execute(Request request, AsyncHandler<T> handler, ListenableFuture<?> future) throws IOException {
119119
if (isClose.get()) {
120120
throw new IOException("Closed");
121121
}
@@ -208,14 +208,14 @@ private final class AsyncHttpUrlConnection<T> implements Callable<T> {
208208
private HttpURLConnection urlConnection;
209209
private Request request;
210210
private final AsyncHandler<T> asyncHandler;
211-
private final FutureImpl<T> future;
211+
private final ListenableFuture<T> future;
212212
private int currentRedirectCount;
213213
private AtomicBoolean isAuth = new AtomicBoolean(false);
214214
private byte[] cachedBytes;
215215
private int cachedBytesLenght;
216216
private boolean terminate = true;
217217

218-
public AsyncHttpUrlConnection(HttpURLConnection urlConnection, Request request, AsyncHandler<T> asyncHandler, FutureImpl<T> future) {
218+
public AsyncHttpUrlConnection(HttpURLConnection urlConnection, Request request, AsyncHandler<T> asyncHandler, ListenableFuture<T> future) {
219219
this.urlConnection = urlConnection;
220220
this.request = request;
221221
this.asyncHandler = asyncHandler;

src/main/java/com/ning/http/client/providers/jdk/JDKDelegateFuture.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
package com.ning.http.client.providers.jdk;
1414

1515
import com.ning.http.client.AsyncHandler;
16-
import com.ning.http.client.FutureImpl;
16+
import com.ning.http.client.ListenableFuture;
1717

1818
import java.net.HttpURLConnection;
1919
import java.util.concurrent.Callable;
@@ -23,16 +23,16 @@
2323

2424
public class JDKDelegateFuture<V> extends JDKFuture<V> {
2525

26-
private final FutureImpl<V> delegateFuture;
26+
private final ListenableFuture<V> delegateFuture;
2727

28-
public JDKDelegateFuture(AsyncHandler<V> asyncHandler, int responseTimeoutInMs, FutureImpl<V> delegateFuture, HttpURLConnection urlConnection) {
28+
public JDKDelegateFuture(AsyncHandler<V> asyncHandler, int responseTimeoutInMs, ListenableFuture<V> delegateFuture, HttpURLConnection urlConnection) {
2929
super(asyncHandler, responseTimeoutInMs, urlConnection);
3030
this.delegateFuture = delegateFuture;
3131
}
3232

3333
public void done(Callable callable) {
34-
isDone.set(true);
3534
delegateFuture.done(callable);
35+
super.done(callable);
3636
}
3737

3838
public void abort(Throwable t) {

src/main/java/com/ning/http/client/providers/jdk/JDKFuture.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
package com.ning.http.client.providers.jdk;
1414

1515
import com.ning.http.client.AsyncHandler;
16-
import com.ning.http.client.FutureImpl;
16+
import com.ning.http.client.ListenableFuture;
17+
import com.ning.http.client.listenable.AbstractListenableFuture;
1718

1819
import java.net.HttpURLConnection;
1920
import java.util.concurrent.Callable;
@@ -27,7 +28,7 @@
2728
import java.util.concurrent.atomic.AtomicReference;
2829

2930

30-
public class JDKFuture<V> implements FutureImpl<V> {
31+
public class JDKFuture<V> extends AbstractListenableFuture<V> {
3132

3233
protected Future<V> innerFuture;
3334
protected final AsyncHandler<V> asyncHandler;
@@ -56,6 +57,7 @@ protected void setInnerFuture(Future<V> innerFuture) {
5657

5758
public void done(Callable callable) {
5859
isDone.set(true);
60+
super.done();
5961
}
6062

6163
public void abort(Throwable t) {

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
181181
socketChannelFactory = new OioClientSocketChannelFactory(config.executorService());
182182
} else {
183183
socketChannelFactory = new NioClientSocketChannelFactory(
184-
Executors.newCachedThreadPool(),
184+
Executors.newFixedThreadPool(100),
185185
config.executorService());
186186
}
187187
plainBootstrap = new ClientBootstrap(socketChannelFactory);

src/main/java/com/ning/http/client/providers/netty/NettyResponseFuture.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
package com.ning.http.client.providers.netty;
1717

1818
import com.ning.http.client.AsyncHandler;
19-
import com.ning.http.client.FutureImpl;
19+
import com.ning.http.client.ListenableFuture;
2020
import com.ning.http.client.Request;
21+
import com.ning.http.client.listenable.AbstractListenableFuture;
2122
import org.jboss.netty.channel.Channel;
2223
import org.jboss.netty.handler.codec.http.HttpRequest;
2324
import org.jboss.netty.handler.codec.http.HttpResponse;
@@ -43,7 +44,7 @@
4344
*
4445
* @param <V>
4546
*/
46-
public final class NettyResponseFuture<V> implements FutureImpl<V> {
47+
public final class NettyResponseFuture<V> extends AbstractListenableFuture<V> {
4748

4849
private final static Logger logger = LoggerFactory.getLogger(NettyResponseFuture.class);
4950
public final static String MAX_RETRY = "com.ning.http.client.providers.netty.maxRetry";
@@ -98,7 +99,6 @@ public NettyResponseFuture(URI uri,
9899

99100
if (System.getProperty(MAX_RETRY) != null) {
100101
maxRetry = Integer.valueOf(System.getProperty(MAX_RETRY));
101-
;
102102
} else {
103103
maxRetry = asyncHttpProvider.getConfig().getMaxRequestRetry();
104104
}
@@ -190,7 +190,7 @@ public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException,
190190
latch.await();
191191
} else {
192192
expired = !latch.await(l, tu);
193-
if (!contentProcessed.get() && expired && l != -1 && ((System.currentTimeMillis() - touch.get()) <= l)) {
193+
if (!contentProcessed.get() && expired && ((System.currentTimeMillis() - touch.get()) <= l)) {
194194
return get(l, tu);
195195
}
196196
}
@@ -239,6 +239,7 @@ V getContent() throws ExecutionException {
239239
}
240240

241241
public final void done(Callable callable) {
242+
super.done();
242243
try {
243244
if (exEx.get() != null) {
244245
return;

src/test/java/com/ning/http/client/async/ListenableFutureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public abstract class ListenableFutureTest extends AbstractBasicTest {
3636

3737
@Test(groups = {"standalone", "default_provider"})
38-
public void testPutEmptyBody() throws Throwable {
38+
public void testListenableFuture() throws Throwable {
3939
final AtomicBoolean executed = new AtomicBoolean(false);
4040
AsyncHttpClient ahc = getAsyncHttpClient(null);
4141
Response response = ((ListenableFuture<Response>)ahc.prepareGet(getTargetUrl()).execute()).addListener(new Runnable(){

0 commit comments

Comments
 (0)