Fixing corner cases

This commit is contained in:
Luca Frosini 2022-06-09 16:17:31 +02:00
parent 615dcd90c8
commit 5947a095f8
2 changed files with 24 additions and 4 deletions

View File

@ -104,8 +104,6 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
Set<UUID> startContextsUUID = new HashSet<>(); Set<UUID> startContextsUUID = new HashSet<>();
for (String token : startTokens) { for (String token : startTokens) {
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
if (create) { if (create) {
ContextUtility.setContextFromToken(token); ContextUtility.setContextFromToken(token);
eServiceManager = new EServiceManager(applicationContext); eServiceManager = new EServiceManager(applicationContext);
@ -113,6 +111,7 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
create = false; create = false;
} else { } else {
try { try {
UUID contextUUID = ContextUtility.getContextUUID(token);
eServiceManager.addToContext(contextUUID); eServiceManager.addToContext(contextUUID);
} catch (Exception e) { } catch (Exception e) {
UUID uuid = UUID.fromString(applicationContext.id()); UUID uuid = UUID.fromString(applicationContext.id());
@ -121,6 +120,16 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
throw e; throw e;
} }
} }
/*
* Do not move this code before having instantiated HostingNodeManager
* which in turn instantiate the ResourceRegistryPublisher
* which in turn initialize ContextCacheRenewal in ContextCache.
* Please note that to properly instantiate ResourceRegistryPublisher
* it is necessary having set a token.
*/
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
} }
Set<UUID> resourceContextsUUID = eServiceManager.getContextsUUID().keySet(); Set<UUID> resourceContextsUUID = eServiceManager.getContextsUUID().keySet();

View File

@ -102,10 +102,10 @@ public class HostingNodeHandler extends ContainerHandler {
List<String> startTokens = containerContext.configuration().startTokens(); List<String> startTokens = containerContext.configuration().startTokens();
Set<UUID> startContextsUUID = new HashSet<>(); Set<UUID> startContextsUUID = new HashSet<>();
for (String token : startTokens) { for (String token : startTokens) {
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
if (create) { if (create) {
ContextUtility.setContextFromToken(token); ContextUtility.setContextFromToken(token);
hostingNodeManager = new HostingNodeManager(containerContext); hostingNodeManager = new HostingNodeManager(containerContext);
@ -113,6 +113,7 @@ public class HostingNodeHandler extends ContainerHandler {
create = false; create = false;
} else { } else {
try { try {
UUID contextUUID = ContextUtility.getContextUUID(token);
hostingNodeManager.addToContext(contextUUID); hostingNodeManager.addToContext(contextUUID);
} catch (Exception e) { } catch (Exception e) {
UUID uuid = UUID.fromString(containerContext.id()); UUID uuid = UUID.fromString(containerContext.id());
@ -121,6 +122,16 @@ public class HostingNodeHandler extends ContainerHandler {
throw e; throw e;
} }
} }
/*
* Do not move this code before having instantiated HostingNodeManager
* which in turn instantiate the ResourceRegistryPublisher
* which in turn initialize ContextCacheRenewal in ContextCache.
* Please note that to properly instantiate ResourceRegistryPublisher
* it is necessary having set a token.
*/
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
} }
Set<UUID> resourceContextsUUID = hostingNodeManager.getContextsUUID().keySet(); Set<UUID> resourceContextsUUID = hostingNodeManager.getContextsUUID().keySet();