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


##########
openjpa-kernel/src/main/java/org/apache/openjpa/event/DynamicTCPRemoteCommitProvider.java:
##########
@@ -51,13 +69,55 @@ public final void setAddresses(final String names) throws 
UnknownHostException {
     public void endConfiguration() {
         TcpAddressesUpdater updater = new TcpAddressesUpdater();
         updater.run();
+        _updater = updater;
 
         Timer timer = new Timer(true);
         timer.scheduleAtFixedRate(updater, 0, _cacheDurationMillis);
 
         super.endConfiguration();
     }
 
+    /**
+     * A peer that just came up may connect before the periodic refresh has 
discovered it, so the addresses are
+     * refreshed before a connection from an unknown host is rejected.
+     */
+    @Override
+    protected boolean refreshesAddressesOnDemand() {
+        return isRestrictToPeers() && _updater != null;
+    }
+
+    /**
+     * Refreshes the addresses, unless a refresh started after the connection 
was accepted. Refreshes run one at a
+     * time and at most once per second, so that connections from unknown 
hosts cannot flood the source of the
+     * addresses.
+     */
+    @Override
+    protected void refreshAddresses(final long acceptedNanos) {

Review Comment:
   nano precision? maybe it should be millis?



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