From 229e427cf168dd8b2aa08dd71b75d9cba6806bb6 Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Fri, 6 Dec 2024 16:59:18 +0100 Subject: [PATCH] temporary change: extend the lock in PageSource to cover all PageSource instances using the same lock name. --- .../main/java/lucee/runtime/PageSourceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/lucee/runtime/PageSourceImpl.java b/core/src/main/java/lucee/runtime/PageSourceImpl.java index a21e6ce77f..d380992841 100755 --- a/core/src/main/java/lucee/runtime/PageSourceImpl.java +++ b/core/src/main/java/lucee/runtime/PageSourceImpl.java @@ -29,6 +29,7 @@ import lucee.print; import lucee.commons.io.IOUtil; +import lucee.commons.io.SystemUtil; import lucee.commons.io.log.Log; import lucee.commons.io.log.LogUtil; import lucee.commons.io.res.Resource; @@ -336,7 +337,7 @@ private Page loadPhysical(PageContext pc, Page page) throws TemplateException { if (page != null) { // if(page!=null && !recompileAlways) { if (srcLastModified != page.getSourceLastModified() || (page instanceof PagePro && ((PagePro) page).getSourceLength() != srcFile.length())) { - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (srcLastModified != page.getSourceLastModified() || (page instanceof PagePro && ((PagePro) page).getSourceLength() != srcFile.length())) { // same size, maybe the content has not changed? boolean same = false; @@ -366,7 +367,7 @@ private Page loadPhysical(PageContext pc, Page page) throws TemplateException { Resource classRootDir = mapping.getClassRootDirectory(); Resource classFile = classRootDir.getRealResource(getJavaName() + ".class"); boolean isNew = false; - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { // new class if (flush || !classFile.exists()) { LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "compile [" + getDisplayPath() + "] no previous class file or flush"); @@ -437,7 +438,7 @@ public boolean releaseWhenOutdatted() { // if(page!=null && !recompileAlways) { if (srcLastModified == 0 || srcLastModified != page.getSourceLastModified()) { // || (page instanceof PagePro && ((PagePro) page).getSourceLength() != srcFile.length()) - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (srcLastModified == 0 || srcLastModified != page.getSourceLastModified()) {// || (page instanceof PagePro && ((PagePro) page).getSourceLength() != // srcFile.length()) if (LogUtil.doesDebug(log)) log.debug("page-source", "release [" + getDisplayPath() + "] from page source pool"); @@ -635,7 +636,7 @@ public Resource getPhyscalFile() { return null; } if (physcalSource == null) { - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (physcalSource == null) { Resource tmp = mapping.getPhysical().getRealResource(relPath); physcalSource = ResourceUtil.toExactResource(tmp); @@ -657,7 +658,7 @@ public Resource getPhyscalFile() { public Resource getArchiveFile() { if (!mapping.hasArchive()) return null; if (archiveSource == null) { - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (archiveSource == null) { String path = "zip://" + mapping.getArchive().getAbsolutePath() + "!" + relPath; archiveSource = ThreadLocalPageContext.getConfig().getResource(path); @@ -671,7 +672,7 @@ public Resource getArchiveClass() { if (!mapping.hasArchive()) return null; if (archiveClass == null) { - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (archiveClass == null) { String path = "zip://" + mapping.getArchive().getAbsolutePath() + "!" + getJavaName() + ".class"; archiveClass = ThreadLocalPageContext.getConfig().getResource(path); @@ -819,7 +820,7 @@ public String getComponentName() { private void createClassAndPackage() { if (className == null) { - synchronized (this) { + synchronized (SystemUtil.createToken("PageSource", getClassName())) { if (className == null) { String str = relPath; StringBuilder packageName = new StringBuilder();