merlimat commented on a change in pull request #6074: PIP-55: Refresh
Authentication Credentials
URL: https://github.com/apache/pulsar/pull/6074#discussion_r370847133
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarChannelInitializer.java
##########
@@ -78,6 +97,19 @@ protected void initChannel(SocketChannel ch) throws
Exception {
// ServerCnx ends up reading higher number of messages and broker can
not throttle the messages by disabling
// auto-read.
ch.pipeline().addLast("flowController", new FlowControlHandler());
- ch.pipeline().addLast("handler", new ServerCnx(pulsar));
+ ServerCnx cnx = new ServerCnx(pulsar);
+ ch.pipeline().addLast("handler", cnx);
+
+ connections.put(ch.remoteAddress(), cnx);
+ }
+
+ private void refreshAuthenticationCredentials() {
+ connections.asMap().values().forEach(cnx -> {
+ try {
+ cnx.refreshAuthenticationCredentials();
+ } catch (Throwable t) {
+ log.warn("[{}] Failed to refresh auth credentials",
cnx.getRemoteAddress());
Review comment:
When we get the ref to `cnx`, it will be a strong ref to it, so we're not
going to loose it during the iteration. Then, inside that method, i'm checking
for
```java
if (getState() != State.Connected || !isActive) {
// Connection is either still being established or already
closed.
return;
}
```
to avoid getting errors on a connections that's already gone
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services