diff --git a/core/src/main/java/lucee/runtime/CFMLFactoryImpl.java b/core/src/main/java/lucee/runtime/CFMLFactoryImpl.java index ddaf1a2a98..5ba2f1bb30 100644 --- a/core/src/main/java/lucee/runtime/CFMLFactoryImpl.java +++ b/core/src/main/java/lucee/runtime/CFMLFactoryImpl.java @@ -73,6 +73,7 @@ import lucee.runtime.type.util.ArrayUtil; import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.ListUtil; +import lucee.runtime.util.PageContextUtil; import lucee.servlet.http.HTTPServletImpl; /** @@ -580,7 +581,7 @@ public Array getInfo() { data.setEL(KeyConstants._urltoken, pc.getURLToken()); try { - if (pc.getConfig().debug()) data.setEL("debugger", pc.getDebugger().getDebuggingData(pc)); + if (PageContextUtil.debug(pc)) data.setEL("debugger", pc.getDebugger().getDebuggingData(pc)); } catch (PageException e2) { } diff --git a/core/src/main/java/lucee/runtime/ComponentPageImpl.java b/core/src/main/java/lucee/runtime/ComponentPageImpl.java index cdd2ba2855..a7a05ef86a 100755 --- a/core/src/main/java/lucee/runtime/ComponentPageImpl.java +++ b/core/src/main/java/lucee/runtime/ComponentPageImpl.java @@ -85,6 +85,7 @@ import lucee.runtime.type.util.ListUtil; import lucee.runtime.type.util.StructUtil; import lucee.runtime.type.util.UDFUtil; +import lucee.runtime.util.PageContextUtil; /** * A Page that can produce Components @@ -174,7 +175,7 @@ public Object call(PageContext pc) throws PageException { // METHOD INVOCATION String qs = ReqRspUtil.getQueryString(pc.getHttpServletRequest()); - if (pc.getBasePageSource() == this.getPageSource() && pc.getConfig().debug()) pc.getDebugger().setOutput(false); + if (pc.getBasePageSource() == this.getPageSource() && PageContextUtil.show(pc)) pc.getDebugger().setOutput(false); boolean isPost = pc.getHttpServletRequest().getMethod().equalsIgnoreCase("POST"); @@ -413,7 +414,7 @@ private void callRest(PageContext pc, Component component, String path, Result r if (status == 404) { String prefix = "no rest service for [" + path + "] found"; - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { msg = prefix + " in" + addDetail; } else { @@ -424,7 +425,7 @@ private void callRest(PageContext pc, Component component, String path, Result r } else if (status == 405) { String prefix = "Unsupported Media Type"; - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { msg = prefix + " for" + addDetail; } else { @@ -435,7 +436,7 @@ else if (status == 405) { } else if (status == 406) { String prefix = "Not Acceptable"; - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { msg = prefix + " for" + addDetail; } else { @@ -547,7 +548,7 @@ else if (!"body".equalsIgnoreCase(restArgSource)) { rtn = component.callWithNamedValues(pc, methodName, args); } catch (PageException e) { - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { throw e; } else { @@ -813,7 +814,7 @@ else if (Decision.isCastableToArray(args)) { } catch (Throwable t) { PageException pe = Caster.toPageException(t); - if (pc.getConfig().debug()) pe.setExposeMessage(true); + if (PageContextUtil.show(pc)) pe.setExposeMessage(true); throw pe; } } diff --git a/core/src/main/java/lucee/runtime/InterfacePageImpl.java b/core/src/main/java/lucee/runtime/InterfacePageImpl.java index 213eab142e..175df5945d 100755 --- a/core/src/main/java/lucee/runtime/InterfacePageImpl.java +++ b/core/src/main/java/lucee/runtime/InterfacePageImpl.java @@ -26,6 +26,7 @@ import lucee.runtime.net.http.ReqRspUtil; import lucee.runtime.op.Caster; import lucee.runtime.type.util.KeyConstants; +import lucee.runtime.util.PageContextUtil; /** * A Page that can produce Components @@ -60,7 +61,7 @@ public Object call(PageContext pc) throws PageException { } String qs = ReqRspUtil.getQueryString(pc.getHttpServletRequest()); - if (pc.getBasePageSource() == this.getPageSource() && pc.getConfig().debug()) pc.getDebugger().setOutput(false); + if (pc.getBasePageSource() == this.getPageSource() && PageContextUtil.debug(pc)) pc.getDebugger().setOutput(false); boolean isPost = pc.getHttpServletRequest().getMethod().equalsIgnoreCase("POST"); // POST diff --git a/core/src/main/java/lucee/runtime/PageContextImpl.java b/core/src/main/java/lucee/runtime/PageContextImpl.java index 070ff061c1..71c164fbba 100644 --- a/core/src/main/java/lucee/runtime/PageContextImpl.java +++ b/core/src/main/java/lucee/runtime/PageContextImpl.java @@ -600,7 +600,7 @@ public void release() { execLog = null; } - if (config.debug()) { + if (PageContextUtil.debug(this)) { boolean skipLogThread = isChild; if (skipLogThread && hasDebugOptions(ConfigPro.DEBUG_THREAD)) skipLogThread = false; if (!skipLogThread && !gatewayContext) config.getDebuggerPool().store(this, debugger); @@ -2765,7 +2765,7 @@ private final void execute(PageSource ps, boolean throwExcpetion, boolean onlyTo setCFOutputOnly((short) 0); } if (!gatewayContext) { - if (getConfig().debug()) { + if (show()) { try { listener.onDebug(this); } @@ -2815,6 +2815,10 @@ public boolean hasDebugOptions(int option) { return getApplicationContext().hasDebugOptions(option); } + public int getDebugOptions() { + return getApplicationContext().getDebugOptions(); + } + private void initallog() { if (!isGatewayContext() && config.isMonitoringEnabled()) { RequestMonitor[] monitors = config.getRequestMonitors(); diff --git a/core/src/main/java/lucee/runtime/config/ConfigImpl.java b/core/src/main/java/lucee/runtime/config/ConfigImpl.java index 5c2145228e..c841443041 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigImpl.java +++ b/core/src/main/java/lucee/runtime/config/ConfigImpl.java @@ -3932,7 +3932,10 @@ protected void setCachedAfterTimeRange(TimeSpan ts) { @Override public TimeSpan getCachedAfterTimeRange() { - if (this.cachedAfterTimeRange != null && this.cachedAfterTimeRange.getMillis() <= 0) this.cachedAfterTimeRange = null; + TimeSpan tmp = this.cachedAfterTimeRange; + if (tmp != null && tmp.getMillis() <= 0) { + this.cachedAfterTimeRange = null; + } return this.cachedAfterTimeRange; } diff --git a/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java b/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java index 6885b660c4..5cd6c2ac8b 100644 --- a/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java +++ b/core/src/main/java/lucee/runtime/debug/DebuggerImpl.java @@ -277,7 +277,7 @@ private ArrayList toArray() { } public static boolean debugQueryUsage(PageContext pageContext, QueryResult qr) { - if (pageContext.getConfig().debug() && qr instanceof Query) { + if (qr instanceof Query) { if (((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_QUERY_USAGE)) { ((Query) qr).enableShowQueryUsage(); return true; @@ -1010,7 +1010,7 @@ public Map>> getGenericData() { } public static void deprecated(PageContext pc, String key, String msg) { - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { // do we already have set? boolean exists = false; Map>> gd = pc.getDebugger().getGenericData(); diff --git a/core/src/main/java/lucee/runtime/debug/DebuggerPool.java b/core/src/main/java/lucee/runtime/debug/DebuggerPool.java index 49f478901f..8c4d73e3d7 100644 --- a/core/src/main/java/lucee/runtime/debug/DebuggerPool.java +++ b/core/src/main/java/lucee/runtime/debug/DebuggerPool.java @@ -26,7 +26,6 @@ import lucee.runtime.config.ConfigWebPro; import lucee.runtime.exp.PageException; import lucee.runtime.net.http.ReqRspUtil; -import lucee.runtime.op.Duplicator; import lucee.runtime.type.Array; import lucee.runtime.type.ArrayImpl; import lucee.runtime.type.Struct; @@ -43,16 +42,15 @@ public DebuggerPool(Resource storage) { public void store(PageContext pc, Debugger debugger) { if (ReqRspUtil.getScriptName(pc, pc.getHttpServletRequest()).indexOf("/lucee/") == 0) return; - synchronized (queue) { - try { - queue.add((Struct) Duplicator.duplicate(debugger.getDebuggingData(pc, true), true)); - } - catch (PageException e) { - } - - while (queue.size() > ((ConfigWebPro) pc.getConfig()).getDebugMaxRecordsLogged()) - queue.poll(); + try { + queue.add(debugger.getDebuggingData(pc, true)); + } + catch (PageException e) { } + + while (queue.size() > ((ConfigWebPro) pc.getConfig()).getDebugMaxRecordsLogged()) + queue.poll(); + } public Array getData(PageContext pc) { diff --git a/core/src/main/java/lucee/runtime/debug/DebuggerUtil.java b/core/src/main/java/lucee/runtime/debug/DebuggerUtil.java index d04d1cf8e4..3366c8eaca 100644 --- a/core/src/main/java/lucee/runtime/debug/DebuggerUtil.java +++ b/core/src/main/java/lucee/runtime/debug/DebuggerUtil.java @@ -65,11 +65,9 @@ private Struct _pointOutClosuresInPersistentScopes(PageContext pc, Struct sct, S } public static boolean debugQueryUsage(PageContext pageContext, Query query) { - if (pageContext.getConfig().debug() && query != null) { - if (((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_QUERY_USAGE)) { - query.enableShowQueryUsage(); - return true; - } + if (((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_QUERY_USAGE)) { + query.enableShowQueryUsage(); + return true; } return false; } diff --git a/core/src/main/java/lucee/runtime/engine/DebugExecutionLog.java b/core/src/main/java/lucee/runtime/engine/DebugExecutionLog.java index 76ef702876..cd4e517d73 100644 --- a/core/src/main/java/lucee/runtime/engine/DebugExecutionLog.java +++ b/core/src/main/java/lucee/runtime/engine/DebugExecutionLog.java @@ -22,6 +22,7 @@ import lucee.runtime.PageContext; import lucee.runtime.debug.DebugEntry; +import lucee.runtime.util.PageContextUtil; public class DebugExecutionLog extends ExecutionLogSupport { @@ -35,7 +36,7 @@ protected void _init(PageContext pc, Map arguments) { @Override protected void _log(int startPos, int endPos, long startTime, long endTime) { - if (!pc.getConfig().debug()) return; + if (!PageContextUtil.debug(pc)) return; long diff = endTime - startTime; if (unit == UNIT_MICRO) diff /= 1000; diff --git a/core/src/main/java/lucee/runtime/functions/decision/IsDebugMode.java b/core/src/main/java/lucee/runtime/functions/decision/IsDebugMode.java index 1b90df40cb..43014f0867 100644 --- a/core/src/main/java/lucee/runtime/functions/decision/IsDebugMode.java +++ b/core/src/main/java/lucee/runtime/functions/decision/IsDebugMode.java @@ -24,10 +24,11 @@ import lucee.runtime.PageContext; import lucee.runtime.debug.DebuggerImpl; import lucee.runtime.ext.function.Function; +import lucee.runtime.util.PageContextUtil; public final class IsDebugMode implements Function { public static boolean call(PageContext pc) { - return pc.getConfig().debug() && (DebuggerImpl.getDebugEntry(pc) != null); + return PageContextUtil.debug(pc) && (DebuggerImpl.getDebugEntry(pc) != null); } } \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/listener/ApplicationContextSupport.java b/core/src/main/java/lucee/runtime/listener/ApplicationContextSupport.java index b065bd39a5..54e4ee1ca0 100644 --- a/core/src/main/java/lucee/runtime/listener/ApplicationContextSupport.java +++ b/core/src/main/java/lucee/runtime/listener/ApplicationContextSupport.java @@ -511,6 +511,8 @@ private static LoggerAndSourceData addLogger(Collection.Key name, int level, Cla public abstract void setShowTest(boolean b); + public abstract int getDebugOptions(); + public abstract boolean hasDebugOptions(int option); public abstract void setDebugOptions(int option); diff --git a/core/src/main/java/lucee/runtime/listener/ClassicAppListener.java b/core/src/main/java/lucee/runtime/listener/ClassicAppListener.java index b8d8407fc8..832e27b63a 100755 --- a/core/src/main/java/lucee/runtime/listener/ClassicAppListener.java +++ b/core/src/main/java/lucee/runtime/listener/ClassicAppListener.java @@ -32,6 +32,7 @@ import lucee.runtime.type.UDF; import lucee.runtime.type.scope.Application; import lucee.runtime.type.scope.Session; +import lucee.runtime.util.PageContextUtil; public final class ClassicAppListener extends AppListenerSupport { @@ -121,7 +122,7 @@ public void onDebug(PageContext pc) throws PageException { public static void _onDebug(PageContext pc) throws PageException { try { - if (pc.getConfig().debug()) pc.getDebugger().writeOut(pc); + if (PageContextUtil.show(pc)) pc.getDebugger().writeOut(pc); } catch (IOException e) { throw Caster.toPageException(e); diff --git a/core/src/main/java/lucee/runtime/listener/ClassicApplicationContext.java b/core/src/main/java/lucee/runtime/listener/ClassicApplicationContext.java index 908690a3e6..82637e034d 100755 --- a/core/src/main/java/lucee/runtime/listener/ClassicApplicationContext.java +++ b/core/src/main/java/lucee/runtime/listener/ClassicApplicationContext.java @@ -1240,6 +1240,11 @@ public boolean hasDebugOptions(int option) { return (debugging & option) > 0; } + @Override + public int getDebugOptions() { + return debugging; + } + @Override public void setDebugOptions(int option) { if (!hasDebugOptions(option)) debugging += option; diff --git a/core/src/main/java/lucee/runtime/listener/ModernAppListener.java b/core/src/main/java/lucee/runtime/listener/ModernAppListener.java index 9f0fbdc245..78bdc25980 100755 --- a/core/src/main/java/lucee/runtime/listener/ModernAppListener.java +++ b/core/src/main/java/lucee/runtime/listener/ModernAppListener.java @@ -75,6 +75,7 @@ import lucee.runtime.type.util.ArrayUtil; import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.UDFUtil; +import lucee.runtime.util.PageContextUtil; public class ModernAppListener extends AppListenerSupport { @@ -266,7 +267,7 @@ private PageException handlePageException(PageContextImpl pci, Component app, Pa else return pe; } else { - if (!pci.isGatewayContext() && pci.getConfig().debug()) { + if (!pci.isGatewayContext() && PageContextUtil.show(pci)) { ((DebuggerImpl) pci.getDebugger()).setAbort(ExceptionUtil.getThrowingPosition(pci, _pe)); } goon.setValue(false); @@ -394,7 +395,7 @@ private PageContextImpl createPageContext(CFMLFactory factory, Component app, St @Override public void onDebug(PageContext pc) throws PageException { - if (((PageContextImpl) pc).isGatewayContext() || !pc.getConfig().debug()) return; + if (((PageContextImpl) pc).isGatewayContext() || !PageContextUtil.show(pc)) return; Component app = getComponent(pc); if (app != null && app.contains(pc, KeyConstants._onDebug)) { call(app, pc, KeyConstants._onDebug, new Object[] { pc.getDebugger().getDebuggingData(pc) }, true); diff --git a/core/src/main/java/lucee/runtime/listener/ModernApplicationContext.java b/core/src/main/java/lucee/runtime/listener/ModernApplicationContext.java index daa3686e69..586c16d5c6 100644 --- a/core/src/main/java/lucee/runtime/listener/ModernApplicationContext.java +++ b/core/src/main/java/lucee/runtime/listener/ModernApplicationContext.java @@ -269,6 +269,7 @@ public class ModernApplicationContext extends ApplicationContextSupport { private boolean initRestSetting; private RestSettings restSetting; private boolean initJavaSettings; + private boolean initJavaSettingsBefore; private JavaSettings javaSettings; private Object ormDatasource; private Locale locale; @@ -1311,6 +1312,12 @@ public void setShowTest(boolean b) { showTest = b; } + @Override + public int getDebugOptions() { + if (!initMonitor) initMonitor(); + return debugging; + } + @Override public boolean hasDebugOptions(int option) { if (!initMonitor) initMonitor(); @@ -1795,12 +1802,18 @@ public void setJavaSettings(JavaSettings javaSettings) { @Override public JavaSettings getJavaSettings() { - initJava(); - return javaSettings; + + return initJava(); } - private void initJava() { + private JavaSettings initJava() { if (!initJavaSettings) { + // PATCH to avoid cycle + if (initJavaSettingsBefore) { + return new JavaSettingsImpl(); + } + initJavaSettingsBefore = true; + Object o = get(component, JAVA_SETTING, null); if (o != null && Decision.isStruct(o)) { try { @@ -1812,7 +1825,9 @@ private void initJava() { } initJavaSettings = true; + initJavaSettingsBefore = false; } + return javaSettings; } @Override diff --git a/core/src/main/java/lucee/runtime/listener/NoneAppListener.java b/core/src/main/java/lucee/runtime/listener/NoneAppListener.java index d33917b540..629c780e70 100755 --- a/core/src/main/java/lucee/runtime/listener/NoneAppListener.java +++ b/core/src/main/java/lucee/runtime/listener/NoneAppListener.java @@ -27,6 +27,7 @@ import lucee.runtime.op.Caster; import lucee.runtime.type.scope.Application; import lucee.runtime.type.scope.Session; +import lucee.runtime.util.PageContextUtil; public final class NoneAppListener extends AppListenerSupport { @@ -76,7 +77,7 @@ public void onSessionEnd(CFMLFactory cfmlFactory, String applicationName, String @Override public void onDebug(PageContext pc) throws PageException { try { - if (pc.getConfig().debug()) pc.getDebugger().writeOut(pc); + if (PageContextUtil.show(pc)) pc.getDebugger().writeOut(pc); } catch (IOException e) { throw Caster.toPageException(e); diff --git a/core/src/main/java/lucee/runtime/rest/RestRequestListener.java b/core/src/main/java/lucee/runtime/rest/RestRequestListener.java index f28df52424..d6e2f703ea 100644 --- a/core/src/main/java/lucee/runtime/rest/RestRequestListener.java +++ b/core/src/main/java/lucee/runtime/rest/RestRequestListener.java @@ -31,6 +31,7 @@ import lucee.runtime.listener.RequestListener; import lucee.runtime.type.Struct; import lucee.runtime.type.util.ListUtil; +import lucee.runtime.util.PageContextUtil; public class RestRequestListener implements RequestListener { @@ -74,7 +75,7 @@ public PageSource execute(PageContext pc, PageSource requestedPage) throws PageE else addDetail = " in the matching mapping [" + mapping.getVirtual() + "] at [" + mapping.getPhysical().getAbsolutePath() + "], available targets are [" + ListUtil.listToListEL(sources, ", ") + "]"; - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { RestUtil.setStatus(pc, 404, HTMLEntities.escapeHTML(msg + addDetail)); } diff --git a/core/src/main/java/lucee/runtime/tag/Admin.java b/core/src/main/java/lucee/runtime/tag/Admin.java index 1d5c648a75..3b3090f491 100755 --- a/core/src/main/java/lucee/runtime/tag/Admin.java +++ b/core/src/main/java/lucee/runtime/tag/Admin.java @@ -192,6 +192,7 @@ import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.ListUtil; import lucee.runtime.type.util.UDFUtil; +import lucee.runtime.util.PageContextUtil; import lucee.transformer.library.ClassDefinitionImpl; import lucee.transformer.library.function.FunctionLib; import lucee.transformer.library.tag.TagLib; @@ -1503,7 +1504,7 @@ private void doGetRegex() throws PageException { * */ private void doGetDebugData() throws PageException { - pageContext.setVariable(getString("admin", action, "returnVariable"), pageContext.getConfig().debug() ? pageContext.getDebugger().getDebuggingData(pageContext) : null); + pageContext.setVariable(getString("admin", action, "returnVariable"), PageContextUtil.debug(pageContext) ? pageContext.getDebugger().getDebuggingData(pageContext) : null); } private void doGetLoggedDebugData() throws PageException { diff --git a/core/src/main/java/lucee/runtime/tag/Cache.java b/core/src/main/java/lucee/runtime/tag/Cache.java index c73b50f5f2..555078a58c 100755 --- a/core/src/main/java/lucee/runtime/tag/Cache.java +++ b/core/src/main/java/lucee/runtime/tag/Cache.java @@ -50,6 +50,7 @@ import lucee.runtime.type.dt.DateTimeImpl; import lucee.runtime.type.dt.TimeSpan; import lucee.runtime.type.dt.TimeSpanImpl; +import lucee.runtime.util.PageContextUtil; /** * Speeds up page rendering when dynamic content does not have to be retrieved each time a user @@ -335,7 +336,7 @@ private void doServerCache() throws IOException, PageException { if (hasBody) hasBody = !StringUtil.isEmpty(body); // call via cfcache disable debugger output - if (pageContext.getConfig().debug()) pageContext.getDebugger().setOutput(false); + if (PageContextUtil.debug(pageContext)) pageContext.getDebugger().setOutput(false); HttpServletResponse rsp = pageContext.getHttpServletResponse(); diff --git a/core/src/main/java/lucee/runtime/tag/Insert.java b/core/src/main/java/lucee/runtime/tag/Insert.java index e38e5bfd67..84b594ce94 100755 --- a/core/src/main/java/lucee/runtime/tag/Insert.java +++ b/core/src/main/java/lucee/runtime/tag/Insert.java @@ -49,6 +49,7 @@ import lucee.runtime.type.scope.Form; import lucee.runtime.type.util.CollectionUtil; import lucee.runtime.type.util.ListUtil; +import lucee.runtime.util.PageContextUtil; /** * Inserts records in data sources. @@ -196,7 +197,7 @@ public int doEndTag() throws PageException { if (sql != null) { QueryImpl query = new QueryImpl(pageContext, dc, sql, -1, -1, null, "query"); - if (pageContext.getConfig().debug()) { + if (PageContextUtil.debug(pageContext)) { String dsn = ds instanceof DataSource ? ((DataSource) ds).getName() : Caster.toString(ds); boolean logdb = ((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_DATABASE); if (logdb) { @@ -204,7 +205,7 @@ public int doEndTag() throws PageException { DebuggerImpl di = (DebuggerImpl) pageContext.getDebugger(); di.addQuery(debugUsage ? query : null, dsn, "", sql, query.getRecordcount(), - Query.toTemplateLine(pageContext.getConfig(), sourceTemplate, pageContext.getCurrentPageSource()), query.getExecutionTime()); + Query.toTemplateLine(pageContext, sourceTemplate, pageContext.getCurrentPageSource()), query.getExecutionTime()); } } diff --git a/core/src/main/java/lucee/runtime/tag/Location.java b/core/src/main/java/lucee/runtime/tag/Location.java index c01f796b1a..69be3b9020 100755 --- a/core/src/main/java/lucee/runtime/tag/Location.java +++ b/core/src/main/java/lucee/runtime/tag/Location.java @@ -35,6 +35,7 @@ import lucee.runtime.listener.ApplicationContext; import lucee.runtime.net.http.ReqRspUtil; import lucee.runtime.op.Caster; +import lucee.runtime.util.PageContextUtil; public final class Location extends TagImpl { @@ -172,7 +173,7 @@ else if (arr.length > 1) { catch (IOException e) { throw Caster.toPageException(e); } - if (pageContext.getConfig().debug()) pageContext.getDebugger().setOutput(false); + if (PageContextUtil.debug(pageContext)) pageContext.getDebugger().setOutput(false); throw new Abort(Abort.SCOPE_REQUEST); } diff --git a/core/src/main/java/lucee/runtime/tag/Query.java b/core/src/main/java/lucee/runtime/tag/Query.java index 3486f4ee00..81e4a2d710 100755 --- a/core/src/main/java/lucee/runtime/tag/Query.java +++ b/core/src/main/java/lucee/runtime/tag/Query.java @@ -99,6 +99,7 @@ import lucee.runtime.type.util.CollectionUtil; import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.ListUtil; +import lucee.runtime.util.PageContextUtil; /** * Passes SQL statements to a data source. Not limited to queries. @@ -553,10 +554,10 @@ public int doEndTag() throws PageException { if (data.async) { PageSource ps = getPageSource(); ((SpoolerEngineImpl) ((ConfigPro) pageContext.getConfig()).getSpoolerEngine()).add(pageContext.getConfig(), - new QuerySpoolerTask(pageContext, data, strSQL, toTemplateLine(pageContext.getConfig(), sourceTemplate, ps), ps)); + new QuerySpoolerTask(pageContext, data, strSQL, toTemplateLine(pageContext, sourceTemplate, ps), ps)); } else { - _doEndTag(pageContext, data, strSQL, toTemplateLine(pageContext.getConfig(), sourceTemplate, getPageSource()), true); // when + _doEndTag(pageContext, data, strSQL, toTemplateLine(pageContext, sourceTemplate, getPageSource()), true); // when // sourceTemplate // exists // getPageSource @@ -739,7 +740,7 @@ else if (!StringUtil.isEmpty(data.name)) { queryResult.setCacheType(cacheHandlerId); } - if (pageContext.getConfig().debug() && data.debug) { + if (PageContextUtil.debug(pageContext) && data.debug) { DebuggerImpl di = (DebuggerImpl) pageContext.getDebugger(); boolean logdb = ((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_DATABASE); if (logdb) { @@ -1175,11 +1176,11 @@ public static TagListener toTagListener(Object listener, TagListener defaultValu return defaultValue; } - public static TemplateLine toTemplateLine(Config config, String sourceTemplate, PageSource ps) { + public static TemplateLine toTemplateLine(PageContext pc, String sourceTemplate, PageSource ps) { if (!StringUtil.isEmpty(sourceTemplate)) { return new TemplateLine(sourceTemplate); } - if (config.debug() || ps == null) { + if (PageContextUtil.debug(pc) || ps == null) { TemplateLine rtn = SystemUtil.getCurrentContext(null); if (rtn != null) return rtn; } diff --git a/core/src/main/java/lucee/runtime/tag/StoredProc.java b/core/src/main/java/lucee/runtime/tag/StoredProc.java index f7d12ec3b8..51214200db 100755 --- a/core/src/main/java/lucee/runtime/tag/StoredProc.java +++ b/core/src/main/java/lucee/runtime/tag/StoredProc.java @@ -76,6 +76,7 @@ import lucee.runtime.type.StructImpl; import lucee.runtime.type.dt.DateTime; import lucee.runtime.type.util.KeyConstants; +import lucee.runtime.util.PageContextUtil; public class StoredProc extends BodyTagTryCatchFinallySupport { // private static final int PROCEDURE_CAT=1; @@ -699,7 +700,7 @@ else if (cacheValue instanceof Struct) { res.set(KeyConstants._executionTime, Caster.toDouble(exe = (System.nanoTime() - startNS))); res.set(KeyConstants._cached, Caster.toBoolean(isFromCache)); - if (pageContext.getConfig().debug() && debug) { + if (PageContextUtil.debug(pageContext) && debug) { boolean logdb = ((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_DATABASE); if (logdb) pageContext.getDebugger().addQuery(null, dsn, procedure, _sql, count, pageContext.getCurrentPageSource(), (int) exe); } diff --git a/core/src/main/java/lucee/runtime/tag/Timer.java b/core/src/main/java/lucee/runtime/tag/Timer.java index 3489e4abf1..3f3ac360ae 100644 --- a/core/src/main/java/lucee/runtime/tag/Timer.java +++ b/core/src/main/java/lucee/runtime/tag/Timer.java @@ -28,6 +28,7 @@ import lucee.runtime.ext.tag.BodyTagImpl; import lucee.runtime.op.Caster; //import lucee.runtime.debug.DebuggerPro; +import lucee.runtime.util.PageContextUtil; public final class Timer extends BodyTagImpl { @@ -174,7 +175,7 @@ else if (TYPE_COMMENT == type) { pageContext.write(""); } else if (TYPE_DEBUG == type) { - if (pageContext.getConfig().debug()) { + if (PageContextUtil.debug(pageContext)) { PageSource curr = pageContext.getCurrentTemplatePageSource(); // TODO need to include unitDesc? // ((DebuggerPro) pageContext.getDebugger()).addTimer(label, exe, curr == null ? "unknown template" diff --git a/core/src/main/java/lucee/runtime/tag/Update.java b/core/src/main/java/lucee/runtime/tag/Update.java index d0cd17e1b9..ec7bc7f989 100755 --- a/core/src/main/java/lucee/runtime/tag/Update.java +++ b/core/src/main/java/lucee/runtime/tag/Update.java @@ -48,6 +48,7 @@ import lucee.runtime.type.util.ArrayUtil; import lucee.runtime.type.util.CollectionUtil; import lucee.runtime.type.util.ListUtil; +import lucee.runtime.util.PageContextUtil; /** * Updates existing records in data sources. @@ -197,14 +198,14 @@ public int doEndTag() throws PageException { if (sql != null) { QueryImpl query = new QueryImpl(pageContext, dc, sql, -1, -1, null, "query"); - if (pageContext.getConfig().debug()) { + if (PageContextUtil.debug(pageContext)) { String dsn = ds instanceof DataSource ? ((DataSource) ds).getName() : Caster.toString(ds); boolean logdb = ((PageContextImpl) pageContext).hasDebugOptions(ConfigPro.DEBUG_DATABASE); if (logdb) { boolean debugUsage = DebuggerUtil.debugQueryUsage(pageContext, query); DebuggerImpl di = (DebuggerImpl) pageContext.getDebugger(); di.addQuery(debugUsage ? query : null, dsn, "", sql, query.getRecordcount(), - Query.toTemplateLine(pageContext.getConfig(), sourceTemplate, pageContext.getCurrentPageSource()), query.getExecutionTime()); + Query.toTemplateLine(pageContext, sourceTemplate, pageContext.getCurrentPageSource()), query.getExecutionTime()); } } diff --git a/core/src/main/java/lucee/runtime/thread/ChildThreadImpl.java b/core/src/main/java/lucee/runtime/thread/ChildThreadImpl.java index 9bd78fd46c..d26d6dbbef 100755 --- a/core/src/main/java/lucee/runtime/thread/ChildThreadImpl.java +++ b/core/src/main/java/lucee/runtime/thread/ChildThreadImpl.java @@ -61,6 +61,7 @@ import lucee.runtime.type.scope.Undefined; import lucee.runtime.type.scope.UndefinedImpl; import lucee.runtime.type.util.KeyConstants; +import lucee.runtime.util.PageContextUtil; public class ChildThreadImpl extends ChildThread implements Serializable { @@ -192,7 +193,7 @@ public PageException execute(Config config) { } ConfigWebPro ci = (ConfigWebPro) pc.getConfig(); - if (!pc.isGatewayContext() && ci.debug()) { + if (!pc.isGatewayContext() && PageContextUtil.debug(pc)) { ((DebuggerImpl) pc.getDebugger()).setThreadName(tagName); if (pc.hasDebugOptions(ConfigPro.DEBUG_TEMPLATE)) debugEntry = pc.getDebugger().getEntry(pc, page.getPageSource()); } diff --git a/core/src/main/java/lucee/runtime/type/scope/ClosureScope.java b/core/src/main/java/lucee/runtime/type/scope/ClosureScope.java index 027a75e15f..ca48c0a4b6 100644 --- a/core/src/main/java/lucee/runtime/type/scope/ClosureScope.java +++ b/core/src/main/java/lucee/runtime/type/scope/ClosureScope.java @@ -27,6 +27,8 @@ import lucee.runtime.Component; import lucee.runtime.ComponentScope; import lucee.runtime.PageContext; +import lucee.runtime.PageContextImpl; +import lucee.runtime.config.ConfigImpl; import lucee.runtime.dump.DumpData; import lucee.runtime.dump.DumpProperties; import lucee.runtime.dump.DumpTable; @@ -55,7 +57,7 @@ public ClosureScope(PageContext pc, Argument arg, Local local, Variables var) { this.arg = arg; this.local = local; this.var = var; - this.debug = pc.getConfig().debug(); + this.debug = ((PageContextImpl) pc).hasDebugOptions(ConfigImpl.DEBUG_IMPLICIT_ACCESS); } /* diff --git a/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java b/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java index b4d9af4311..8643622315 100755 --- a/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java +++ b/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java @@ -53,6 +53,7 @@ import lucee.runtime.type.util.CollectionUtil; import lucee.runtime.type.util.KeyConstants; import lucee.runtime.type.util.StructSupport; +import lucee.runtime.util.PageContextUtil; import lucee.runtime.util.QueryStack; import lucee.runtime.util.QueryStackImpl; @@ -242,7 +243,7 @@ public Object get(PageContext pc, Collection.Key key) throws PageException { } } - if (pc.getConfig().debug()) { + if (PageContextUtil.show(pc)) { String msg = ExceptionUtil.similarKeyMessage(this, key.getString(), "key", "keys", null, false); String detail = ExceptionUtil.similarKeyMessage(this, key.getString(), "keys", null, false); throw new ExpressionException(msg, detail); diff --git a/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerDatasource.java b/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerDatasource.java index 88b8fb35ab..fca57a3246 100644 --- a/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerDatasource.java +++ b/core/src/main/java/lucee/runtime/type/scope/storage/IKHandlerDatasource.java @@ -58,10 +58,12 @@ public IKStorageValue loadData(PageContext pc, String appName, String name, Stri if (dc != null) ((DatasourceConnectionPro) dc).release(); } - if (query != null && config.debug()) { + if (query != null) { boolean debugUsage = DebuggerUtil.debugQueryUsage(pc, query); - if (debugUsage) pc.getDebugger().addQuery(debugUsage ? query : null, name, "", query.getSql(), query.getRecordcount(), - ((PageContextImpl) pc).getCurrentPageSource(null), query.getExecutionTime()); + if (debugUsage) { + pc.getDebugger().addQuery(debugUsage ? query : null, name, "", query.getSql(), query.getRecordcount(), ((PageContextImpl) pc).getCurrentPageSource(null), + query.getExecutionTime()); + } } boolean _isNew = query.getRecordcount() == 0; diff --git a/core/src/main/java/lucee/runtime/type/util/StructSupport.java b/core/src/main/java/lucee/runtime/type/util/StructSupport.java index 2420354bed..ee5eed965b 100755 --- a/core/src/main/java/lucee/runtime/type/util/StructSupport.java +++ b/core/src/main/java/lucee/runtime/type/util/StructSupport.java @@ -41,6 +41,7 @@ import lucee.runtime.type.UDF; import lucee.runtime.type.dt.DateTime; import lucee.runtime.type.it.KeyAsStringIterator; +import lucee.runtime.util.PageContextUtil; public abstract class StructSupport implements Map, Struct { @@ -64,7 +65,7 @@ public static ExpressionException invalidKey(Config config, Struct sct, Key key, config = ThreadLocalPageContext.getConfig(config); String msg = ExceptionUtil.similarKeyMessage(sct, key.getString(), "key", "keys", in, true); String detail = ExceptionUtil.similarKeyMessage(sct, key.getString(), "keys", in, true); - if (config != null && config.debug()) return new ExpressionException(msg, detail); + if (config != null && PageContextUtil.debug(ThreadLocalPageContext.get(config))) return new ExpressionException(msg, detail); return new ExpressionException("key [" + key.getString() + "] doesn't exist" + appendix); } diff --git a/core/src/main/java/lucee/runtime/util/PageContextUtil.java b/core/src/main/java/lucee/runtime/util/PageContextUtil.java index 063462a270..da9ac06c47 100644 --- a/core/src/main/java/lucee/runtime/util/PageContextUtil.java +++ b/core/src/main/java/lucee/runtime/util/PageContextUtil.java @@ -282,4 +282,14 @@ public static boolean hasDebugOptions(PageContext pc, int option) { if (c instanceof ConfigPro) return ((ConfigPro) c).hasDebugOptions(option); return false; } + + public static boolean debug(PageContext pc) { + if (pc != null) return ((PageContextImpl) pc).getDebugOptions() > 0; + return false; + } + + public static boolean show(PageContext pc) { + if (pc != null) return ((PageContextImpl) pc).show(); + return false; + } } \ No newline at end of file diff --git a/loader/build.xml b/loader/build.xml index 0c4c034eef..5add0194cc 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index cea6e1ceb4..ff99ed79f6 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.1.1.46-SNAPSHOT + 6.1.1.47-SNAPSHOT jar Lucee Loader Build