Source:
<code>public SiteContext getContext(String siteName, boolean fallback) { SiteContext siteContext = contextRegistry.get(siteName); if (siteContext == null) { if(!fallbackSite.equals(siteName)) { try { entitlementValidator.validateEntitlement(Module.ENGINE, EntitlementType.SITE, <START> (int) contextRegistry.entrySet().stream() <END> .filter(entry -> !fallbackSite.equals(entry.getKey())) .count(), 1); } catch (EntitlementException e) { return null; } } lock.lock(); try { siteContext = contextRegistry.get(siteName); if (siteContext == null) { logger.info("=================================================="); logger.info("<Creating site context: " + siteName + ">"); logger.info("=================================================="); if (fallback) { siteContext = fallbackContextFactory.createContext(siteName); siteContext.setFallback(true); } else { siteContext = contextFactory.createContext(siteName); } publishEvent(new SiteContextCreatedEvent(siteContext, this), siteContext); contextRegistry.put(siteName, siteContext); logger.info("Site context created: " + siteContext); logger.info("=================================================="); logger.info("</Creating site context: " + siteName + ">"); logger.info("=================================================="); } } catch (RootFolderNotFoundException e) { logger.error("Cannot resolve root folder for site '" + siteName + "'", e); } finally { lock.unlock(); } } else { if (!siteContext.isValid()) { logger.error("Site context " + siteContext + " is not valid anymore"); destroyContext(siteName); siteContext = null; } } return siteContext; }</code><technical_language>Get out .count() call out in a variable clearer</technical_language>

Target:
public SiteContext getContext(String siteName, boolean fallback) { SiteContext siteContext = contextRegistry.get(siteName); if (siteContext == null) { if(!fallback) { try { int totalSites = (int) contextRegistry.values().stream() .filter(context -> !context.isFallback()) .count(); entitlementValidator.validateEntitlement(Module.ENGINE, EntitlementType.SITE, totalSites, 1); } catch (EntitlementException e) { return null; } } lock.lock(); try { siteContext = contextRegistry.get(siteName); if (siteContext == null) { logger.info("=================================================="); logger.info("<Creating site context: " + siteName + ">"); logger.info("=================================================="); if (fallback) { siteContext = fallbackContextFactory.createContext(siteName); siteContext.setFallback(true); } else { siteContext = contextFactory.createContext(siteName); } publishEvent(new SiteContextCreatedEvent(siteContext, this), siteContext); contextRegistry.put(siteName, siteContext); logger.info("Site context created: " + siteContext); logger.info("=================================================="); logger.info("</Creating site context: " + siteName + ">"); logger.info("=================================================="); } } catch (RootFolderNotFoundException e) { logger.error("Cannot resolve root folder for site '" + siteName + "'", e); } finally { lock.unlock(); } } else { if (!siteContext.isValid()) { logger.error("Site context " + siteContext + " is not valid anymore"); destroyContext(siteName); siteContext = null; } } return siteContext; }