diff --git a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java index 7b3671d974..ef71cbbd9f 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java +++ b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java @@ -575,7 +575,7 @@ protected static void updateMapping(ConfigPro config, String virtual, String phy admin._updateMapping(virtual, physical, archive, primary, inspect, inspectTemplateIntervalSlow, inspectTemplateIntervalFast, toplevel, listenerMode, listenerType, readonly); admin._store(); - ConfigUtil.getConfigWebImpl(config).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); if (reload) admin._reload(); } @@ -4734,7 +4734,7 @@ public void updateRHExtension(Config config, RHExtension rhext, boolean reload, String sub = subFolder(entry); logger.log(Log.LEVEL_DEBUG, "extension", "deploy mapping " + sub); updateArchive(zis, sub, false); - ConfigUtil.getConfigWebImpl(config).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); reloadNecessary = true; } @@ -5022,7 +5022,7 @@ else if (!StringUtil.isEmpty(cfc, true)) { toplevel = Caster.toBooleanValue(map.get("toplevel"), false); readonly = Caster.toBooleanValue(map.get("readonly"), false); _updateMapping(virtual, physical, archive, primary, inspect, inspectTemplateIntervalSlow, inspectTemplateIntervalFast, toplevel, lmode, ltype, readonly); - ConfigUtil.getConfigWebImpl(config).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); reloadNecessary = true; logger.debug("extension", "Update Mapping [" + virtual + "]"); diff --git a/core/src/main/java/lucee/runtime/config/ConfigPro.java b/core/src/main/java/lucee/runtime/config/ConfigPro.java index 3c40220be8..6b330a25f4 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigPro.java +++ b/core/src/main/java/lucee/runtime/config/ConfigPro.java @@ -413,4 +413,6 @@ public Resource[] getResources(PageContext pc, Mapping[] mappings, String realPa public CFMLEngine getEngine(); public boolean getDateCasterClassicStyle(); + + public ConfigPro resetMappings(); } diff --git a/core/src/main/java/lucee/runtime/config/ConfigUtil.java b/core/src/main/java/lucee/runtime/config/ConfigUtil.java index faf3cb4883..4548161c84 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigUtil.java +++ b/core/src/main/java/lucee/runtime/config/ConfigUtil.java @@ -1458,12 +1458,17 @@ public static ConfigServerImpl getConfigServerImpl(Config config) { throw new RuntimeException("getConfigServerImpl: " + config.getClass().getName()); } - public static ConfigWebImpl getConfigWebImpl(Config config) { + /** + * returns ConfigWeb if available, otherwise ConfigServer + * + * @param config + * @return + */ + public static ConfigPro getConfigWebIfPossible(Config config) { if (config instanceof ConfigWebImpl) return ((ConfigWebImpl) config); Config c = ThreadLocalPageContext.getConfig(); - LogUtil.log(Log.LEVEL_ERROR, "config", "canno convert the following instance to a ConfigWebImpl: " + config.getClass().getName()); if (c instanceof ConfigWebImpl) return ((ConfigWebImpl) c); - // MUST remove - throw new RuntimeException("getConfigWebImpl: " + config.getClass().getName()); + + return getConfigServerImpl(config); } } \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java b/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java index dcd7e325ac..377c991892 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java +++ b/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java @@ -21,7 +21,6 @@ import org.osgi.framework.Version; -import lucee.print; import lucee.commons.collection.MapFactory; import lucee.commons.io.SystemUtil; import lucee.commons.io.cache.Cache; @@ -1805,17 +1804,14 @@ public Mapping[] getMappings() { // Mapping Map mappings = MapFactory.getConcurrentMap(existing.length + 1); boolean finished = false; - for (Mapping m: existing) { if ("/".equals(m.getVirtual())) finished = true; - - print.e(m.getVirtual() + ":" + m); MappingImpl tmp = ((MappingImpl) m).cloneReadOnly(this); mappings.put(tmp.getVirtualLowerCase(), tmp); } - if (!finished) { + Mapping m; if (ResourceUtil.isUNCPath(getRootDirectory().getPath())) { m = new MappingImpl(this, "/", getRootDirectory().getPath(), null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, @@ -1834,60 +1830,7 @@ public Mapping[] getMappings() { return mappings; } - private void createMapping() { - Map existing = null;// getExistingMappings(); - - // Mapping - Map mappings = MapFactory.getConcurrentMap(); - Mapping tmp; - boolean finished = false; - Mapping ex; - Mapping[] sm = cs.getMappings(); - if (sm != null) { - for (int i = 0; i < sm.length; i++) { - if (!sm[i].isHidden()) { - if ("/".equals(sm[i].getVirtual())) finished = true; - ex = existing.get(sm[i].getVirtualLowerCase()); - if (ex != null && ex.equals(sm[i])) { - mappings.put(ex.getVirtualLowerCase(), ex); - continue; - } - else if (sm[i] instanceof MappingImpl) { - tmp = ((MappingImpl) sm[i]).cloneReadOnly(this); - mappings.put(tmp.getVirtualLowerCase(), tmp); - - } - else { - tmp = sm[i]; - mappings.put(tmp.getVirtualLowerCase(), tmp); - } - - if (ex instanceof MappingImpl) { - ((MappingImpl) ex).flush(); - } - - } - } - } - if (!finished) { - Mapping m; - if (ResourceUtil.isUNCPath(getRootDirectory().getPath())) { - m = new MappingImpl(this, "/", getRootDirectory().getPath(), null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, - ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, true, true, true, false, false, null, -1, -1); - } - else { - m = new MappingImpl(this, "/", "/", null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, true, true, - true, false, false, null, -1, -1, true, true); - } - ex = existing.get("/"); - if (ex != null && ex.equals(m)) { - m = ex; - } - mappings.put("/", m); - } - this.mappings = ConfigUtil.sort(mappings.values().toArray(new Mapping[mappings.size()])); - } - + @Override public ConfigWebImpl resetMappings() { if (mappings != null) { synchronized (SystemUtil.createToken("ConfigWebImpl", "getMappings")) { diff --git a/core/src/main/java/lucee/runtime/tag/Admin.java b/core/src/main/java/lucee/runtime/tag/Admin.java index f4a155a8e8..53983ceb0b 100755 --- a/core/src/main/java/lucee/runtime/tag/Admin.java +++ b/core/src/main/java/lucee/runtime/tag/Admin.java @@ -1022,7 +1022,7 @@ else if (mappingType == MAPPING_CT) { mapping.getInspectTemplateRaw(), mapping.getInspectTemplateAutoIntervalRaw(true), mapping.getInspectTemplateAutoIntervalRaw(false), mapping.isTopLevel(), mapping.getListenerMode(), mapping.getListenerType(), mapping.isReadonly()); store(); - ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); } } @@ -2059,7 +2059,7 @@ private void doGetComponentMappings() throws PageException { private void doRemoveMapping() throws PageException { admin.removeMapping(getString("admin", action, "virtual")); store(); - ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); adminSync.broadcast(attributes, config); } @@ -2093,7 +2093,7 @@ private void doUpdateMapping() throws PageException { ); store(); - ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); + ConfigUtil.getConfigWebIfPossible(config).resetMappings(); adminSync.broadcast(attributes, config); } diff --git a/loader/src/main/java/lucee/loader/osgi/BundleLoader.java b/loader/src/main/java/lucee/loader/osgi/BundleLoader.java index 65379e5479..462da53029 100644 --- a/loader/src/main/java/lucee/loader/osgi/BundleLoader.java +++ b/loader/src/main/java/lucee/loader/osgi/BundleLoader.java @@ -170,7 +170,7 @@ private static Map loadAvailableBundles(final File jarDirectory) { final Map rtn = new ConcurrentHashMap<>(); final File[] jars = jarDirectory.listFiles(); - if (jars != null) { + if (jars != null && jars.length > 0) { // Create a thread pool with a fixed number of threads // ExecutorService executor = Executors.newFixedThreadPool(Math.min(jars.length, // Runtime.getRuntime().availableProcessors())); @@ -226,7 +226,9 @@ private static Map loadAvailableBundlesSerial(final File jarDirect } public static ExecutorService createExecutorService(int maxThreads) { - + if (maxThreads <= 0) { + throw new IllegalArgumentException("Invalid value for maxThreads: " + maxThreads + ". The value must be greater than 0."); + } if (parseJavaVersion(System.getProperty("java.version")) >= 19) { // FUTURE use newVirtualThreadPerTaskExecutor natively try {