Skip to content

Commit

Permalink
Merge branch '6.1.0' of https://github.com/lucee/Lucee into 6.1.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	loader/build.xml
#	loader/pom.xml
  • Loading branch information
cfmitrah committed Jun 27, 2024
2 parents b03147d + 76d6e50 commit 0cf94ae
Show file tree
Hide file tree
Showing 25 changed files with 203 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import lucee.commons.digest.HashUtil;
import lucee.commons.io.IOUtil;
import lucee.commons.io.SystemUtil;
import lucee.commons.io.log.LogUtil;
import lucee.commons.io.res.Resource;
import lucee.commons.io.res.util.ResourceClassLoader;
Expand Down Expand Up @@ -125,7 +126,7 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {

@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
synchronized (this) {
synchronized (SystemUtil.createToken("pcl", name)) {
return loadClass(name, resolve, true);
}
}
Expand Down Expand Up @@ -153,7 +154,7 @@ private Class<?> loadClass(String name, boolean resolve, boolean loadFromFS) thr

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {// if(name.indexOf("sub")!=-1)print.ds(name);
synchronized (this) {
synchronized (SystemUtil.createToken("pcl", name)) {
Resource res = directory.getRealResource(name.replace('.', '/').concat(".class"));

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand All @@ -175,7 +176,7 @@ private Class<?> loadClass(String name, boolean resolve, boolean loadFromFS) thr
public Class<?> loadClass(String name, byte[] barr) throws UnmodifiableClassException {
Class<?> clazz = null;

synchronized (this) {
synchronized (SystemUtil.createToken("pcl", name)) {

// new class , not in memory yet
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public Object get(int access, Key key, Object defaultValue) {

@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp, int access) {
return toDumpData(pageContext, maxlevel, dp, access);
return component.toDumpData(pageContext, maxlevel, dp, access);
}

@Override
Expand Down
216 changes: 93 additions & 123 deletions core/src/main/java/lucee/runtime/PageContextImpl.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/main/java/lucee/runtime/SuperComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public Object get(int access, Key key, Object defaultValue) {

@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp, int access) {
return toDumpData(pageContext, maxlevel, dp, access);
return comp.toDumpData(pageContext, maxlevel, dp, access);
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/lucee/runtime/debug/DebuggerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,18 @@ public static boolean debugQueryUsage(PageContext pageContext, Query query) {
}
return false;
}

public static boolean hasCustomDebugEntry(PageContext pc) {

String addr = pc.getHttpServletRequest().getRemoteAddr();
lucee.runtime.config.DebugEntry debugEntry = ((ConfigPro) pc.getConfig()).getDebugEntry(addr, null);
return debugEntry != null;
}

public static boolean hasDebugOptions(PageContext pc) {
PageContextImpl pci = (PageContextImpl) pc;
return pci.hasDebugOptions(ConfigPro.DEBUG_DATABASE) || pci.hasDebugOptions(ConfigPro.DEBUG_DUMP) || pci.hasDebugOptions(ConfigPro.DEBUG_EXCEPTION)
|| pci.hasDebugOptions(ConfigPro.DEBUG_IMPLICIT_ACCESS) || pci.hasDebugOptions(ConfigPro.DEBUG_QUERY_USAGE) || pci.hasDebugOptions(ConfigPro.DEBUG_TEMPLATE)
|| pci.hasDebugOptions(ConfigPro.DEBUG_THREAD) || pci.hasDebugOptions(ConfigPro.DEBUG_TIMER) || pci.hasDebugOptions(ConfigPro.DEBUG_TRACING);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {
return call(pc, Caster.toString(args[0]));
}

public static String call(PageContext pc, String markdown) throws PageException {
public static String call(PageContext pc, String markdown) {
return call(pc, markdown, false, null);
}

public static String call(PageContext pc, String markdown, boolean safeMode) throws PageException {
public static String call(PageContext pc, String markdown, boolean safeMode) {
return call(pc, markdown, safeMode, null);
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/lucee/runtime/java/JavaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ private Object init(Object[] arguments) throws PageException {
}

private Object init(Object[] arguments, Object defaultValue) {
object = Reflector.callConstructor(clazz, arguments, defaultValue);
isInit = object != defaultValue;
return object;
object = Reflector.callConstructor(clazz, arguments, null);
isInit = object != null;
return isInit ? object : defaultValue;
}

@Override
Expand Down
43 changes: 21 additions & 22 deletions core/src/main/java/lucee/runtime/tag/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import lucee.runtime.PageContextImpl;
import lucee.runtime.debug.DebuggerImpl;
import lucee.runtime.debug.DebuggerUtil;
import lucee.runtime.exp.PageException;
import lucee.runtime.exp.PageExceptionImpl;
import lucee.runtime.ext.tag.BodyTagImpl;
Expand Down Expand Up @@ -50,56 +51,54 @@ public void setRequesttimeout(double requesttimeout) {
}

/**
* set the value showdebugoutput Yes or No. When set to No, showDebugOutput suppresses debugging
* information that would otherwise display at the end of the generated page.Default is Yes.
* for backward compatibility reason this setting only works enables debugging, if there is a custom
* debug template and at least one debug setting is enabled
*
* @param showdebugoutput value to set
**/
public void setShowdebugoutput(boolean showdebugoutput) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowDebug(showdebugoutput);
acs.setShowDoc(showdebugoutput);
acs.setShowMetric(showdebugoutput);
acs.setShowTest(showdebugoutput);
public void setShowdebugoutput(boolean show) {
if (show) {
if (!DebuggerUtil.hasCustomDebugEntry(pageContext)) return;
if (!DebuggerUtil.hasDebugOptions(pageContext)) return;
}
setShowdebug(show);
}

public void setShow(boolean showdebugoutput) {
public void setShow(boolean show) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowDebug(showdebugoutput);
acs.setShowDoc(showdebugoutput);
acs.setShowMetric(showdebugoutput);
acs.setShowTest(showdebugoutput);
acs.setShowDebug(show);
acs.setShowDoc(show);
acs.setShowMetric(show);
acs.setShowTest(show);
}
}

public void setShowdebug(boolean showdebugoutput) {
public void setShowdebug(boolean show) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowDebug(showdebugoutput);
acs.setShowDebug(show);
}
}

public void setShowmetric(boolean showdebugoutput) {
public void setShowmetric(boolean show) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowMetric(showdebugoutput);
acs.setShowMetric(show);
}
}

public void setShowdoc(boolean showdebugoutput) {
public void setShowdoc(boolean show) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowDoc(showdebugoutput);
acs.setShowDoc(show);
}
}

public void setShowtest(boolean showdebugoutput) {
public void setShowtest(boolean show) {
ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
if (acs != null) {
acs.setShowTest(showdebugoutput);
acs.setShowTest(show);
}
}

Expand Down
21 changes: 13 additions & 8 deletions core/src/main/java/lucee/runtime/tag/ThreadTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final class ThreadTag extends BodyTagImpl implements DynamicAttributes {

private int action = ACTION_RUN;
private long duration = -1;
private Collection.Key _name;
private Collection.Key name;
private int priority = Thread.NORM_PRIORITY;
private long timeout = 0;
private PageContext pc;
Expand All @@ -103,7 +103,7 @@ public void release() {
super.release();
action = ACTION_RUN;
duration = -1;
_name = null;
name = null;
priority = Thread.NORM_PRIORITY;
type = TYPE_DAEMON;
plans = EXECUTION_PLAN;
Expand Down Expand Up @@ -142,17 +142,17 @@ public void setSeparatescopes(boolean separateScopes) {
*/
public void setName(String name) {
if (StringUtil.isEmpty(name, true)) return;
this._name = KeyImpl.init(name);
this.name = KeyImpl.init(name);
}

private Collection.Key name(boolean create) {
if (_name == null && create) _name = KeyImpl.init("thread" + RandomUtil.createRandomStringLC(20));
return _name;
if (name == null && create) name = KeyImpl.init("thread" + RandomUtil.createRandomStringLC(5));
return name;
}

private String nameAsString(boolean create) {
public String nameAsString(boolean create) {
name(create);
return _name == null ? null : _name.getString();
return name == null ? null : name.getString();
}

/**
Expand Down Expand Up @@ -296,7 +296,11 @@ public int doEndTag() throws PageException {
}

public void register(Page currentPage, int threadIndex) throws PageException {
if (ACTION_RUN != action) return;
_register(currentPage, threadIndex);
}

public String _register(Page currentPage, int threadIndex) throws PageException {
if (ACTION_RUN != action) return null;

Key name = name(true);
try {
Expand Down Expand Up @@ -327,6 +331,7 @@ public void register(Page currentPage, int threadIndex) throws PageException {
finally {
((PageContextImpl) pc).reuse(this);// this method is not called from template when type is run, a call from template is to early,
}
return name.getString();
}

private static PageContext getRootPageContext(PageContext pc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ public boolean isAllowImplicidQueryCall() {
@Override
public boolean setAllowImplicidQueryCall(boolean allowImplicidQueryCall) {
boolean old = pc.allowImplicidQueryCall();
((ApplicationContextSupport) pc.getApplicationContext()).setAllowImplicidQueryCall(allowImplicidQueryCall);
// this.allowImplicidQueryCall = allowImplicidQueryCall;
pc.getApplicationContext().setAllowImplicidQueryCall(allowImplicidQueryCall);
return old;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import lucee.runtime.db.ClassDefinition;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.TemplateException;
import lucee.runtime.functions.other.CreateUniqueId;
import lucee.runtime.tag.TagUtil;
import lucee.runtime.type.scope.Scope;
import lucee.runtime.type.util.ArrayUtil;
Expand Down Expand Up @@ -278,22 +277,18 @@ else if (listener != null) {

private Type _writeOutListener(BytecodeContext bc, int mode, Boolean asCollection) throws TransformerException {
GeneratorAdapter ga = bc.getAdapter();
// TODO better way to get it?
String name = "threadListener:" + Long.toString(System.currentTimeMillis(), Character.MAX_RADIX) + CreateUniqueId.invoke();
LitString lname = bc.getFactory().createLitString(name);
TagThread tt = new TagThread(bc.getFactory(), getStart(), listener.getEnd());
TagLibTag tlt = TagUtil.getTagLibTag((ConfigPro) ThreadLocalPageContext.getConfig(), "cf", "thread");
tt.outputName();
tt.setTagLibTag(tlt);
tt.addAttribute(new Attribute(false, "action", bc.getFactory().createLitString("run"), "string"));
tt.addAttribute(new Attribute(false, "separatescopes", bc.getFactory().createLitBoolean(false), "boolean"));
tt.addAttribute(new Attribute(false, "name", lname, "string"));
Body body = tt.getBody();
body.addStatement(new TryCatch(bc.getFactory(), getStart(), listener.getEnd(), this, listener, asCollection));
tt.setBody(body);
tt.setParent(bc.getPage());
tt.init();
tt._writeOut(bc);
lname.writeOut(bc, Expression.MODE_REF);
return Types.STRING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ public final class TagThread extends TagBaseNoFinal implements ATagThread {
public static final Type THREAD_TAG = Type.getType(ThreadTag.class);

private static final Method REGISTER = new Method("register", Types.VOID, new Type[] { Types.PAGE, Types.INT_VALUE });
private static final Method _REGISTER = new Method("_register", Types.STRING, new Type[] { Types.PAGE, Types.INT_VALUE });

private int index;

private boolean outputName;

public TagThread(Factory f, Position start, Position end) {
super(f, start, end);
// print.e("::::"+ASMUtil.getAttributeString(this, "action","run")+":"+hashCode());
}

public void outputName() {
this.outputName = true;
}

public void init() throws TransformerException {
String action = ASMUtil.getAttributeString(this, "action", "run");
// no body
Expand Down Expand Up @@ -80,8 +87,7 @@ public void _writeOut(BytecodeContext bc) throws TransformerException {
adapter.loadLocal(bc.getCurrentTag());
adapter.loadThis();
adapter.push(index);
adapter.invokeVirtual(THREAD_TAG, REGISTER);

adapter.invokeVirtual(THREAD_TAG, outputName ? _REGISTER : REGISTER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ public final class DynamicClassLoader extends ExtendableClassLoader {
boolean res = registerAsParallelCapable();
}
private Resource directory;
// private final Set<ClassLoader> parents = new HashSet<>();

private Map<String, String> loadedClasses = new ConcurrentHashMap<String, String>();
private Map<String, String> allLoadedClasses = new ConcurrentHashMap<String, String>(); // this includes all renames
private Map<String, String> unavaiClasses = new ConcurrentHashMap<String, String>();
private final Map<String, String> loadedClasses = new ConcurrentHashMap<>();
private final Map<String, String> allLoadedClasses = new ConcurrentHashMap<>(); // this includes all renames
private final Map<String, String> unavaiClasses = new ConcurrentHashMap<>();

private Map<String, SoftReference<Object>> instances = new ConcurrentHashMap<String, SoftReference<Object>>();
private final Map<String, SoftReference<Object>> instances = new ConcurrentHashMap<>();

private static long counter = 0L;
private static long _start = 0L;
private static String start = Long.toString(_start, Character.MAX_RADIX);
private static Object countToken = new Object();
private static final Object countToken = new Object();

public static String uid() {
synchronized (countToken) {
Expand Down Expand Up @@ -114,7 +113,7 @@ public Object loadInstance(String name) throws ClassNotFoundException, Instantia
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
// First, check if the class has already been loaded
synchronized (this) {
synchronized (SystemUtil.createToken("dcl", name)) {
return loadClass(name, resolve, true);
}
}
Expand Down
11 changes: 10 additions & 1 deletion core/src/main/java/resource/context/admin/info/Info.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
"metric":"ldMetric"
,"ref":"loadRef"
];

// this should never happen
if(len(enabledKeys)==0){
return;
}

// only show the debug template
if(len(enabledKeys)==1 && (arguments.show.debug?:false) && !isNull(arguments.debugTemplate) && ((getMetaData(arguments.debugTemplate).fullname?:"")!="lucee.admin.debug.Modern")) {
arguments.debugTemplate.output(custom:arguments.debugArgs.custom,debugging:arguments.debugArgs.debugging);
return;
}
</cfscript>

</td></td></td></th></th></th></tr></tr></tr></table></table></table></a></abbrev></acronym></address></applet></au></b></banner></big></blink></blockquote></bq></caption></center></cite></code></comment></del></dfn></dir></div></div></dl></em></fig></fn></font></form></frame></frameset></h1></h2></h3></h4></h5></h6></head></i></ins></kbd></listing></map></marquee></menu></multicol></nobr></noframes></noscript></note></ol></p></param></person></plaintext></pre></q></s></samp></script></select></small></strike></strong></sub></sup></table></td></textarea></th></title></tr></tt></u></ul></var></wbr></xmp>
Expand Down
14 changes: 12 additions & 2 deletions core/src/main/java/resource/tld/core-base.tld
Original file line number Diff line number Diff line change
Expand Up @@ -5645,9 +5645,19 @@ To use cached data, the current query must use the same SQL statement, data sour
<type>boolean</type>
<name>showDebugOutput</name>
<required>false</required>
<status>deprecated</status>
<rtexprvalue>true</rtexprvalue>
<description>Yes or No. When set to No, showDebugOutput suppresses monitor information that would
otherwise display at the end of the generated page.</description>
<description>
This attribute is deprecated, use instead one of the following attributes:
- showDebug
- showMetrics
- showDoc
- showTest
- show

This attributes emulates as close as possible the behaviour of previous Lucee versions (6.0 or smaller).
This attribute only takes effect when a custom debug template is defined in the Lucee admin and at least one debug option is enabled.
</description>
</attribute>
<attribute>
<type>boolean</type>
Expand Down
Loading

0 comments on commit 0cf94ae

Please sign in to comment.