Skip to content

Commit

Permalink
LDEV-4602 - shifting the sync
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 6, 2024
1 parent a7360d4 commit 7163e0b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions core/src/main/java/lucee/runtime/PageSourceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,18 @@ private Page loadPhysical(PageContext pc, Page page) throws TemplateException {
Resource classRootDir = mapping.getClassRootDirectory();
Resource classFile = classRootDir.getRealResource(getJavaName() + ".class");
boolean isNew = false;
synchronized (this) {
{
// new class
if (flush || !classFile.exists()) {
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "compile [" + getDisplayPath() + "] no previous class file or flush");
synchronized (this) {
if (flush || !classFile.exists()) {
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "compile [" + getDisplayPath() + "] no previous class file or flush");

pcn.set(page = compile(config, classRootDir, null, false, pc.ignoreScopes()));
flush = false;
isNew = true;
pcn.set(page = compile(config, classRootDir, null, false, pc.ignoreScopes()));
flush = false;
isNew = true;
}
}
}
// load page
else {
Expand Down Expand Up @@ -405,17 +409,21 @@ private Page loadPhysical(PageContext pc, Page page) throws TemplateException {
pcn.reset();
}
if (page == null) {
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "compile [" + getDisplayPath() + "] in case loading of the class fails");
pcn.set(page = compile(config, classRootDir, null, false, pc.ignoreScopes()));
isNew = true;
synchronized (this) {
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "compile [" + getDisplayPath() + "] in case loading of the class fails");
pcn.set(page = compile(config, classRootDir, null, false, pc.ignoreScopes()));
isNew = true;
}
}
}

// check if version changed or lasMod
if (!isNew && (srcLastModified != page.getSourceLastModified() || page.getVersion() != pc.getConfig().getFactory().getEngine().getInfo().getFullVersionInfo())) {
isNew = true;
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "recompile [" + getDisplayPath() + "] because unloaded page has changed");
pcn.set(page = compile(config, classRootDir, page, false, pc.ignoreScopes()));
synchronized (this) {
isNew = true;
LogUtil.log(pc, Log.LEVEL_DEBUG, "compile", "recompile [" + getDisplayPath() + "] because unloaded page has changed");
pcn.set(page = compile(config, classRootDir, page, false, pc.ignoreScopes()));
}
}
page.setPageSource(this);
page.setLoadType(LOAD_PHYSICAL);
Expand Down Expand Up @@ -459,7 +467,7 @@ private boolean isLoad(byte load) {
return page != null && load == page.getLoadType();
}

private synchronized Page compile(ConfigWeb config, Resource classRootDir, Page existing, boolean returnValue, boolean ignoreScopes) throws TemplateException {
private Page compile(ConfigWeb config, Resource classRootDir, Page existing, boolean returnValue, boolean ignoreScopes) throws TemplateException {
try {
return _compile(config, classRootDir, existing, returnValue, ignoreScopes, false);
}
Expand Down

0 comments on commit 7163e0b

Please sign in to comment.