Skip to content

Commit

Permalink
temporary change: extend the lock in PageSource to cover all PageSour…
Browse files Browse the repository at this point in the history
…ce instances using the same lock name.
  • Loading branch information
michaeloffner committed Dec 6, 2024
1 parent ee211c0 commit 229e427
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/src/main/java/lucee/runtime/PageSourceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 229e427

Please sign in to comment.