Permalink
Browse files

Merge pull request #607 from FortnoxAB/patch-2

PooledConnection.close must be subscribed to to be executed
  • Loading branch information...
jamesgorman2 committed May 27, 2018
2 parents 52dc281 + 4038885 commit b5a747b6862af10b3e67e57eda4fa3e0336e1dfb
@@ -33,6 +33,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Subscriber;
import rx.functions.Action1;
import rx.functions.Actions;
import rx.observers.SafeSubscriber;
import rx.subscriptions.Subscriptions;
@@ -138,7 +140,13 @@ private void newConnectionReuseEvent(Channel channel, final ConnectionReuseEvent
subscriber.onNext(event.getPooledConnection());
checkEagerSubscriptionIfConfigured(channel);
} else {
event.getPooledConnection().close(false); // If pooled connection not sent to the subscriber, release to the pool.
// If pooled connection not sent to the subscriber, release to the pool.
event.getPooledConnection().close(false).subscribe(Actions.empty(), new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
logger.error("Error closing connection.", throwable);
}
});
}
}

0 comments on commit b5a747b

Please sign in to comment.