Skip to content

Commit b746367

Browse files
miklishMichael Christoff
andauthored
Issue1897 (#1980)
* refactorings: SimpleConnectionHolder -> SimpleConnectionState, SimpleClientConnection -> SimpleUndertowConnection, and SimpleClientConnectionMaker -> SimpleUndertowConnectionMaker * 1. Breaking Changes: Renamed SimpleConnectionHolder -> SimpleConnectionState, SimpleClientConnection -> SimpleUndertowConnection, SimpleClientConnectionMaker -> SimpleUndertowConnectionMaker, and removed the reuseConnection() method from the SimpleConnectionMaker interface. 2. Performance optimizations. 3. Numerous refactorings 4. Major update to documentation 5. Minor re-organization of connection management logic * fix accidental removal of fix from PR #1963 * ensure that debug logging helper code (such as loglabel() and ports() etc...) is not run unless debug logging is enabled * ensure that SimpleUndertowConnectionMaker can only have a single instance in a multithreaded environment by making its instance reference volatile and making its default constructor private * Make Correction to comments in ConsulRegistry.lookupServiceUpdate to explain how serviceUrls.size() == 0 will ensure that updateServiceCache() does not modify the service IP cache * Small formatting update --------- Co-authored-by: Michael Christoff <[email protected]>
1 parent 6c9069c commit b746367

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

consul/src/main/java/com/networknt/consul/ConsulRegistry.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ private ConcurrentHashMap<String, List<URL>> lookupServiceUpdate(String protocol
326326
{
327327
logger.info("Got updated urls from Consul: {} instances of service {} found", services.size(), serviceName);
328328

329-
// - Update has occurred: Ensure that the serviceUrls Map has at least one (possibly empty List)
330-
// entry for the serviceName key.
331-
// This will ensure that updateServiceCache() will do an update.
329+
// Update has occurred - Ensure that the serviceUrls Map has at least one (possibly empty) List
330+
// entry for the serviceName key. This will indicate to updateServiceCache() to do an update:
331+
// - serviceUrls.size() > 0
332332
if(services.size() == 0)
333333
serviceUrls.put(serviceName, new ArrayList<>());
334334

@@ -365,12 +365,12 @@ private ConcurrentHashMap<String, List<URL>> lookupServiceUpdate(String protocol
365365
lookupServices.put(serviceName, 0L);
366366

367367
// Indicate to updateServiceCache() to leave cache unchanged for now:
368-
// - serviceUrls.isEmpty() == true && serviceUrls.get(serviceName) != null && serviceUrls.get(serviceName).size() == 0
368+
// - serviceUrls.size() == 0
369369
} else {
370370
logger.info("Consul returned no service updates: No need to update local Consul discovery cache for service {}, lastIndex={}", serviceName, lastConsulIndexId);
371371

372372
// Indicate to updateServiceCache() to leave cache unchanged for now:
373-
// - serviceUrls.isEmpty() == true && serviceUrls.get(serviceName) != null && serviceUrls.get(serviceName).size() == 0
373+
// - serviceUrls.size() == 0
374374
}
375375
} else {
376376
logger.error("Local service cache may be out of date for {} - Consul connection failed", serviceName);

0 commit comments

Comments
 (0)