Skip to content

Commit

Permalink
Extract the ConnectionListener creation in a separate method in Pool
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed May 25, 2018
1 parent 1bb6445 commit a4d13b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/io/vertx/core/http/impl/pool/Pool.java
Expand Up @@ -237,9 +237,8 @@ private void checkPending() {
}
}

private void createConnection(Waiter<C> waiter) {
Holder<C> holder = new Holder<>();
ConnectionListener<C> listener = new ConnectionListener<C>() {
private ConnectionListener<C> createListener(Holder<C> holder) {
return new ConnectionListener<C>() {
@Override
public void onConcurrencyChange(long concurrency) {
synchronized (Pool.this) {
Expand All @@ -259,6 +258,7 @@ public void onConcurrencyChange(long concurrency) {
}
}
}

@Override
public void onRecycle(long expirationTimestamp) {
if (expirationTimestamp < 0L) {
Expand All @@ -271,6 +271,7 @@ public void onRecycle(long expirationTimestamp) {
recycle(holder, 1, expirationTimestamp);
}
}

@Override
public void onDiscard() {
synchronized (Pool.this) {
Expand All @@ -281,6 +282,11 @@ public void onDiscard() {
}
}
};
}

private void createConnection(Waiter<C> waiter) {
Holder<C> holder = new Holder<>();
ConnectionListener<C> listener = createListener(holder);
connector.connect(listener, waiter.context, ar -> {
if (ar.succeeded()) {
ConnectResult<C> result = ar.result();
Expand Down

0 comments on commit a4d13b6

Please sign in to comment.