Skip to content

Commit d22a28a

Browse files
committed
Clean up: have the future return its partitionId
1 parent 8e2023f commit d22a28a

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/main/java/com/ning/http/client/providers/netty/channel/ChannelManager.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,6 @@ public void upgradeProtocol(ChannelPipeline pipeline, String scheme, String host
430430
}
431431
}
432432

433-
public String getPartitionId(NettyResponseFuture<?> future) {
434-
return future.getConnectionPoolPartitioning().getPartitionId(future.getUri(), future.getProxyServer());
435-
}
436-
437433
public void verifyChannelPipeline(ChannelPipeline pipeline, String scheme) throws IOException, GeneralSecurityException {
438434

439435
boolean sslHandlerConfigured = isSslHandlerConfigured(pipeline);
@@ -471,7 +467,7 @@ public void call() {
471467
}
472468

473469
public void drainChannelAndOffer(final Channel channel, final NettyResponseFuture<?> future) {
474-
drainChannelAndOffer(channel, future, future.isKeepAlive(), getPartitionId(future));
470+
drainChannelAndOffer(channel, future, future.isKeepAlive(), future.getPartitionId());
475471
}
476472

477473
public void drainChannelAndOffer(final Channel channel, final NettyResponseFuture<?> future, boolean keepAlive, String poolKey) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ public long getStart() {
424424
return start;
425425
}
426426

427+
public String getPartitionId() {
428+
return connectionPoolPartitioning.getPartitionId(uri, proxyServer);
429+
}
430+
427431
@Override
428432
public String toString() {
429433
return "NettyResponseFuture{" + //

src/main/java/com/ning/http/client/providers/netty/handler/HttpProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private void finishUpdate(final NettyResponseFuture<?> future, Channel channel,
185185
if (expectOtherChunks && keepAlive)
186186
channelManager.drainChannelAndOffer(channel, future);
187187
else
188-
channelManager.tryToOfferChannelToPool(channel, keepAlive, channelManager.getPartitionId(future));
188+
channelManager.tryToOfferChannelToPool(channel, keepAlive, future.getPartitionId());
189189
markAsDone(future, channel);
190190
}
191191

src/main/java/com/ning/http/client/providers/netty/handler/Protocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected boolean exitAfterHandlingRedirect(//
144144

145145
// in case of a redirect from HTTP to HTTPS, future attributes might change
146146
final boolean initialConnectionKeepAlive = future.isKeepAlive();
147-
final String initialPoolKey = channelManager.getPartitionId(future);
147+
final String initialPoolKey = future.getPartitionId();
148148

149149
future.setUri(uri);
150150
String newUrl = uri.toUrl();

src/main/java/com/ning/http/client/providers/netty/request/NettyRequestSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private <T> ListenableFuture<T> sendRequestWithNewChannel(//
271271
// only compute when maxConnectionPerHost is enabled
272272
// FIXME clean up
273273
if (config.getMaxConnectionsPerHost() > 0)
274-
poolKey = channelManager.getPartitionId(future);
274+
poolKey = future.getPartitionId();
275275
channelManager.preemptChannel(poolKey);
276276

277277
channelPreempted = true;

0 commit comments

Comments
 (0)