Skip to content

Commit

Permalink
Merge branch '6.0' of https://github.com/lucee/Lucee into 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Sep 18, 2023
2 parents 33ac0fb + 2ac622a commit 3b6375c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.23.0</version>
<version>1.24.0</version>
</dependency>
<dependency>
<groupId>org.lucee</groupId>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Export-Package: coldfusion,
lucee.transformer.cfml.script.java.function
Require-Bundle: org.apache.commons.commons-codec;bundle-version=1.15.0,
org.apache.commons.commons-collections4;bundle-version=4.4.0,
org.apache.commons.commons-compress;bundle-version=1.23.0,
org.apache.commons.commons-compress;bundle-version=1.24.0,
org.apache.commons.commons-fileupload;bundle-version=1.5.0,
org.apache.commons.commons-io;bundle-version=2.11.0,
org.apache.commons.lang3;bundle-version=3.12.0,
Expand Down
53 changes: 27 additions & 26 deletions core/src/main/java/lucee/runtime/MappingImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public final class MappingImpl implements Mapping {
private transient PCLCollection pcoll;
private Resource archive;

private boolean hasArchive;
private final Config config;
private Resource classRootDirectory;
private final PageSourcePool pageSourcePool = new PageSourcePool();
Expand Down Expand Up @@ -136,8 +135,8 @@ public MappingImpl(Config config, String virtual, String strPhysical, String str
this.config = config;
this.hidden = hidden;
this.readonly = readonly;
this.strPhysical = StringUtil.isEmpty(strPhysical) ? null : strPhysical;
this.strArchive = StringUtil.isEmpty(strArchive) ? null : strArchive;
this.strPhysical = StringUtil.isEmpty(strPhysical, true) ? null : strPhysical.trim();
this.strArchive = StringUtil.isEmpty(strArchive, true) ? null : strArchive.trim();
this.inspect = inspect;
this.topLevel = topLevel;
this.appMapping = appMapping;
Expand All @@ -154,23 +153,24 @@ public MappingImpl(Config config, String virtual, String strPhysical, String str
else this.virtual = virtual;
this.lcVirtual = this.virtual.toLowerCase();
this.lcVirtualWithSlash = lcVirtual.endsWith("/") ? this.lcVirtual : this.lcVirtual + '/';
}

private void initPhysical() {
ServletContext cs = (config instanceof ConfigWeb) ? ((ConfigWeb) config).getServletContext() : null;

// Physical
physical = ConfigWebUtil.getExistingResource(cs, strPhysical, null, config.getConfigDir(), FileUtil.TYPE_DIR, config, checkPhysicalFromWebroot);
// Archive

if (archive == null) this.physicalFirst = true;
else if (physical == null) this.physicalFirst = false;

}

private void initArchive() {
ServletContext cs = (config instanceof ConfigWeb) ? ((ConfigWeb) config).getServletContext() : null;
archive = ConfigWebUtil.getExistingResource(cs, strArchive, null, config.getConfigDir(), FileUtil.TYPE_FILE, config, checkArchiveFromWebroot);
loadArchive();

hasArchive = archive != null;

if (archive == null) this.physicalFirst = true;
else if (physical == null) this.physicalFirst = false;
else this.physicalFirst = physicalFirst;

// if(!hasArchive && !hasPhysical) throw new IOException("missing physical and archive path, one of
// them must be defined");
}

private void loadArchive() {
Expand All @@ -179,7 +179,7 @@ private void loadArchive() {
CFMLEngine engine = ConfigWebUtil.getEngine(config);
BundleContext bc = engine.getBundleContext();
try {
archiveBundle = OSGiUtil.installBundle(bc, archive, true);
archiveBundle = OSGiUtil.installBundle(bc, getArchive(), true);
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
Expand All @@ -191,6 +191,7 @@ private void loadArchive() {

@Override
public Class<?> getArchiveClass(String className) throws ClassNotFoundException {
getArchive();// this calls init the archive if necessary
if (archiveBundle != null) {
return archiveBundle.loadClass(className);
}
Expand All @@ -200,6 +201,7 @@ public Class<?> getArchiveClass(String className) throws ClassNotFoundException

@Override
public Class<?> getArchiveClass(String className, Class<?> defaultValue) {
getArchive();// this calls init the archive if necessary
try {
if (archiveBundle != null) return archiveBundle.loadClass(className);
// else if(archiveClassLoader!=null) return archiveClassLoader.loadClass(className);
Expand Down Expand Up @@ -272,7 +274,6 @@ public Class<?> getPhysicalClass(String className, Class<?> defaultValue) {

@Override
public Class<?> getPhysicalClass(String className, byte[] code) throws IOException {

try {
return touchPhysicalClassLoader(className.contains("_cfc$cf")).loadClass(className, code);
}
Expand Down Expand Up @@ -304,6 +305,7 @@ public void resetPages(ClassLoader cl) {

@Override
public Resource getPhysical() {
if (physical == null && strPhysical != null) initPhysical(); // possible that the target path only exists AFTER startup
return physical;
}

Expand All @@ -319,18 +321,18 @@ public String getVirtualLowerCaseWithSlash() {

@Override
public Resource getArchive() {
// initArchive();
if (archive == null && strArchive != null) initArchive(); // possible that the target path only exists AFTER startup
return archive;
}

@Override
public boolean hasArchive() {
return hasArchive;
return getArchive() != null;
}

@Override
public boolean hasPhysical() {
return physical != null;
return getPhysical() != null;
}

@Override
Expand Down Expand Up @@ -423,18 +425,13 @@ public void check() {
ServletContext cs = (config instanceof ConfigWeb) ? ((ConfigWeb) config).getServletContext() : null;

// Physical
if (getPhysical() == null && strPhysical != null && strPhysical.length() > 0) {
physical = ConfigWebUtil.getExistingResource(cs, strPhysical, null, config.getConfigDir(), FileUtil.TYPE_DIR, config, checkPhysicalFromWebroot);
if (getPhysical() == null && strPhysical != null) {
initPhysical();

}
// Archive
if (getArchive() == null && strArchive != null && strArchive.length() > 0) {

archive = ConfigWebUtil.getExistingResource(cs, strArchive, null, config.getConfigDir(), FileUtil.TYPE_FILE, config, checkArchiveFromWebroot);
loadArchive();

hasArchive = archive != null;

if (getArchive() == null && strArchive != null) {
initArchive();
}
}

Expand All @@ -450,6 +447,10 @@ public boolean isHidden() {

@Override
public boolean isPhysicalFirst() {
// make sure everything is loaded
getArchive();
getPhysical();
// now we can trust the result
return physicalFirst;
}

Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.23.0</version>
<version>1.24.0</version>
</dependency>
<dependency>
<groupId>org.lucee</groupId>
Expand Down

0 comments on commit 3b6375c

Please sign in to comment.