solomax commented on code in PR #293:
URL: https://github.com/apache/openjpa/pull/293#discussion_r4522640709


##########
openjpa-kernel/src/main/java/org/apache/openjpa/event/TCPRemoteCommitProvider.java:
##########
@@ -282,10 +325,55 @@ public void setAddresses(final String names) throws 
UnknownHostException {
                 }
             }
         } finally {
+            addressesChanged();
             _addressesLock.unlock();
         }
     }
 
+    /**
+     * Updates the addresses from which incoming connections are accepted. 
Must be invoked, while holding
+     * {@link #_addressesLock}, whenever {@link #_addresses} has been changed.
+     */
+    protected void addressesChanged() {
+        _peerAddresses = 
_addresses.stream().map(HostAddress::getAddress).collect(Collectors.toUnmodifiableSet());
+    }
+
+    /**
+     * Whether this provider accepts an incoming connection from the given 
address. Connections from this host are
+     * always accepted; connections from other hosts only if they are one of 
the configured peers, unless
+     * {@link #setRestrictToPeers(boolean) RestrictToPeers} is turned off. The 
port of the peers is not considered, as
+     * the peers connect from arbitrary local ports.
+     *
+     * @param address the address of the remote end of the incoming connection
+     * @return <code>true</code> if the connection is accepted
+     */
+    protected boolean acceptsConnectionFrom(final InetAddress address) {
+        return !_restrictToPeers || address.isLoopbackAddress() || 
localAddresses.contains(address)

Review Comment:
   Is it possible to have `address.isLoopbackAddress()` and 
`!localAddresses.contains(address)` ?
   
   I was sure `localAddresses` must contains them all :)



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to