Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import io.micrometer.core.instrument.MeterRegistry;
import io.netty.util.AttributeMap;

import static java.util.Objects.requireNonNull;

/**
* Listens to the client connection pool events.
*/
Expand Down Expand Up @@ -122,4 +124,19 @@ void connectionClosed(SessionProtocol protocol,
default ConnectionPoolListener unwrap() {
return this;
}

default ConnectionPoolListener doThen(ConnectionPoolListener anotherConnectionPoolListener) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default ConnectionPoolListener doThen(ConnectionPoolListener anotherConnectionPoolListener) {
default ConnectionPoolListener andThen(ConnectionPoolListener anotherConnectionPoolListener) {

requireNonNull(anotherConnectionPoolListener, "anotherConnectionPoolListener");
return new ConnectionPoolListener() {
@Override
public void connectionOpen(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception {
anotherConnectionPoolListener.connectionOpen(protocol, remoteAddr, localAddr, attrs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expectation is that this#connectionOpen is called, and then anotherConnectionPoolListener#connectionOpen is called (hence "chained").

Can you also add a test to confirm this behavior?

Suggested change
anotherConnectionPoolListener.connectionOpen(protocol, remoteAddr, localAddr, attrs);
connectionOpen(protocol, remoteAddr, localAddr, attrs);
anotherConnectionPoolListener.connectionOpen(protocol, remoteAddr, localAddr, attrs);

}

@Override
public void connectionClosed(SessionProtocol protocol, InetSocketAddress remoteAddr, InetSocketAddress localAddr, AttributeMap attrs) throws Exception {
anotherConnectionPoolListener.connectionClosed(protocol, remoteAddr, localAddr, attrs);
}
};
}
}