normanmaurer commented on a change in pull request #753: ZOOKEEPER-3204:
Reconfig tests are constantly failing on 3.5 after applying Java 11 fix
URL: https://github.com/apache/zookeeper/pull/753#discussion_r254181520
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxnFactory.java
##########
@@ -528,14 +508,30 @@ private void addCnxn(NettyServerCnxn cnxn) {
cnxns.add(cnxn);
synchronized (ipMap){
InetAddress addr =
- ((InetSocketAddress)cnxn.channel.getRemoteAddress())
- .getAddress();
+
((InetSocketAddress)cnxn.getChannel().remoteAddress()).getAddress();
Set<NettyServerCnxn> s = ipMap.get(addr);
if (s == null) {
- s = new HashSet<NettyServerCnxn>();
+ s = new HashSet<>();
+ ipMap.put(addr, s);
}
s.add(cnxn);
- ipMap.put(addr,s);
+ }
+ }
+
+ void removeCnxnFromIpMap(NettyServerCnxn cnxn, InetAddress remoteAddress) {
+ synchronized (ipMap) {
+ Set<NettyServerCnxn> s = ipMap.get(remoteAddress);
+ if (s != null) {
+ s.remove(cnxn);
+ if (s.isEmpty()) {
+ ipMap.remove(remoteAddress);
+ }
+ } else {
+ LOG.error(
Review comment:
nit: I would consider moving the logging out of the synchronized block as
logging may be slow depending on the logger etc
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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