diff --git a/core/src/main/java/lucee/runtime/component/ComponentLoader.java b/core/src/main/java/lucee/runtime/component/ComponentLoader.java index b618cfdad2..f03e0bd179 100755 --- a/core/src/main/java/lucee/runtime/component/ComponentLoader.java +++ b/core/src/main/java/lucee/runtime/component/ComponentLoader.java @@ -18,10 +18,9 @@ */ package lucee.runtime.component; -import java.util.concurrent.ConcurrentHashMap; - import javax.servlet.jsp.tagext.BodyContent; +import lucee.commons.io.SystemUtil; import lucee.commons.io.res.Resource; import lucee.commons.io.res.filter.DirectoryResourceFilter; import lucee.commons.io.res.filter.ExtensionResourceFilter; @@ -65,7 +64,6 @@ public class ComponentLoader { private static final short RETURN_TYPE_PAGE = 1; private static final short RETURN_TYPE_INTERFACE = 2; private static final short RETURN_TYPE_COMPONENT = 3; - private static final ConcurrentHashMap tokens = new ConcurrentHashMap(); private static final ResourceFilter DIR_OR_EXT = new OrResourceFilter( new ResourceFilter[] { DirectoryResourceFilter.FILTER, new ExtensionResourceFilter(Constants.getComponentExtensions()) }); private static final ImportDefintion[] EMPTY_ID = new ImportDefintion[0]; @@ -103,7 +101,7 @@ public static StaticScope getStaticScope(PageContext pc, PageSource loadingLocat // if there is no static scope stored yet, we need to load it if (ss == null) { - synchronized (cp.getPageSource().getDisplayPath() + ":" + getToken(cp.getHash() + "")) { + synchronized (SystemUtil.createToken(cp.getPageSource().getDisplayPath(), cp.getHash() + "")) { ss = cp.getStaticScope(); if (ss == null) { ss = searchComponent(pc, loadingLocation, rawPath, searchLocal, searchRoot, false, false).staticScope(); @@ -696,11 +694,4 @@ private static CIPage toCIPage(Page p) { return null; } - public static String getToken(String key) { - String lock = tokens.putIfAbsent(key, key); - if (lock == null) { - lock = key; - } - return lock; - } } \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/db/DatasourceManagerImpl.java b/core/src/main/java/lucee/runtime/db/DatasourceManagerImpl.java index 9ec5a3a2f7..07cc534075 100755 --- a/core/src/main/java/lucee/runtime/db/DatasourceManagerImpl.java +++ b/core/src/main/java/lucee/runtime/db/DatasourceManagerImpl.java @@ -30,6 +30,7 @@ import lucee.commons.db.DBUtil; import lucee.commons.digest.HashUtil; import lucee.commons.io.IOUtil; +import lucee.commons.io.SystemUtil; import lucee.commons.lang.Pair; import lucee.runtime.PageContext; import lucee.runtime.PageContextImpl; @@ -55,7 +56,6 @@ public final class DatasourceManagerImpl implements DataSourceManager { private int isolation = Connection.TRANSACTION_NONE; private Map transConnsReg = new HashMap(); private Map transConnsORM = new HashMap(); - private static final ConcurrentHashMap tokens = new ConcurrentHashMap(); private boolean inside; private Map savepoints = new ConcurrentHashMap<>(); @@ -86,7 +86,7 @@ public DatasourceConnection getConnection(PageContext pc, DataSource ds, String // first time that datasource is used within this transaction if (existingDC == null) { - synchronized (getToken(ds.id())) { + synchronized (SystemUtil.createToken("DatasourceManagerImpl", ds.id())) { existingDC = transConnsReg.get(ds); if (existingDC == null) { DatasourceConnectionPro newDC = (DatasourceConnectionPro) config.getDatasourceConnectionPool().getDatasourceConnection(config, ds, user, pass); @@ -495,12 +495,4 @@ private void throwException(Pair pair) throws D private int _size() { return transConnsORM.size() + transConnsReg.size(); } - - public static String getToken(String key) { - String lock = tokens.putIfAbsent(key, key); - if (lock == null) { - lock = key; - } - return lock; - } } \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/reflection/storage/SoftMethodStorage.java b/core/src/main/java/lucee/runtime/reflection/storage/SoftMethodStorage.java index fc256a290b..89e8df5976 100644 --- a/core/src/main/java/lucee/runtime/reflection/storage/SoftMethodStorage.java +++ b/core/src/main/java/lucee/runtime/reflection/storage/SoftMethodStorage.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import lucee.commons.io.SystemUtil; import lucee.runtime.type.Collection; import lucee.runtime.type.Collection.Key; import lucee.runtime.type.KeyImpl; @@ -34,7 +35,6 @@ */ public final class SoftMethodStorage { - private final ConcurrentHashMap tokens = new ConcurrentHashMap(); private Map>>> map = new ConcurrentHashMap>>>(); /** @@ -94,7 +94,7 @@ public int compare(Method l, Method r) { * @return returns stored struct */ private Map> store(Class clazz) { - synchronized (getToken(clazz)) { + synchronized (SystemUtil.createToken("SoftMethodStorage", clazz.getName())) { Method[] methods = clazz.getMethods(); Map> methodsMap = new ConcurrentHashMap>(); for (int i = 0; i < methods.length; i++) { @@ -105,15 +105,6 @@ private Map> store(Class clazz) { } } - private Object getToken(Class clazz) { - Object newLock = new Object(); - Object lock = tokens.putIfAbsent(clazz.getName(), newLock); - if (lock == null) { - lock = newLock; - } - return lock; - } - /** * stores a single method * diff --git a/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerCache.java b/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerCache.java index 6ff6114915..34c48dd278 100644 --- a/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerCache.java +++ b/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerCache.java @@ -19,7 +19,6 @@ import lucee.runtime.type.scope.ScopeContext; public class IKHandlerCache implements IKHandler { - private static final ConcurrentHashMap tokens = new ConcurrentHashMap(); protected boolean storeEmpty = Caster.toBooleanValue(SystemUtil.getSystemPropOrEnvVar("lucee.store.empty", null), true); @@ -33,7 +32,7 @@ public class IKHandlerCache implements IKHandler { public IKStorageValue loadData(PageContext pc, String appName, String name, String strType, int type, Log log) throws PageException { Cache cache = getCache(pc, name); String key = getKey(pc.getCFID(), appName, strType); - synchronized (getToken(key)) { // sync necessary? + synchronized (SystemUtil.createToken("IKHandlerCache", key)) { // sync necessary? Object val = cache.getValue(key, null); if (val instanceof byte[][]) { ScopeContext.info(log, @@ -58,7 +57,7 @@ public void store(IKStorageScopeSupport storageScope, PageContext pc, String app Cache cache = getCache(ThreadLocalPageContext.get(pc), name); String key = getKey(pc.getCFID(), appName, storageScope.getTypeAsString()); - synchronized (getToken(key)) { + synchronized (SystemUtil.createToken("IKHandlerCache", key)) { Object existingVal = cache.getValue(key, null); if (storeEmpty || storageScope.hasContent()) { @@ -101,7 +100,7 @@ public void unstore(IKStorageScopeSupport storageScope, PageContext pc, String a Cache cache = getCache(pc, name); String key = getKey(pc.getCFID(), appName, storageScope.getTypeAsString()); - synchronized (getToken(key)) { + synchronized (SystemUtil.createToken("IKHandlerCache", key)) { cache.remove(key); } } @@ -129,12 +128,4 @@ public static String getKey(String cfid, String appName, String type) { return new StringBuilder("lucee-storage:").append(type).append(":").append(cfid).append(":").append(appName).toString().toUpperCase(); } - public static Object getToken(String key) { - Object newLock = new Object(); - Object lock = tokens.putIfAbsent(key, newLock); - if (lock == null) { - lock = newLock; - } - return lock; - } } diff --git a/loader/build.xml b/loader/build.xml index a12b05ee34..35bc61618e 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index ff7bcdd7c2..8b8618cc3b 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.0.1.18-SNAPSHOT + 6.0.1.19-SNAPSHOT jar Lucee Loader Build