Skip to content

Commit dd58c68

Browse files
committed
LDEV-1402 cleanup
1 parent 5515d3b commit dd58c68

File tree

6 files changed

+38
-41
lines changed

6 files changed

+38
-41
lines changed

core/src/main/java/lucee/runtime/PageContextImpl.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
import lucee.runtime.debug.DebuggerRegistry;
115115
import lucee.runtime.dump.DumpUtil;
116116
import lucee.runtime.dump.DumpWriter;
117+
import lucee.runtime.engine.DebuggerExecutionLog;
117118
import lucee.runtime.engine.ExecutionLog;
118119
import lucee.runtime.err.ErrorPage;
119120
import lucee.runtime.err.ErrorPageImpl;
@@ -3531,15 +3532,14 @@ public void removeUDF() {
35313532
* inspect variables in any frame, not just the current one.
35323533
*/
35333534
public static final class DebuggerFrame {
3534-
public final lucee.runtime.type.scope.Local local;
3535-
public final lucee.runtime.type.scope.Argument arguments;
3536-
public final lucee.runtime.type.scope.Variables variables;
3535+
public final Local local;
3536+
public final Argument arguments;
3537+
public final Variables variables;
35373538
public final PageSource pageSource;
35383539
public final String functionName;
35393540
private volatile int line;
35403541

3541-
DebuggerFrame(lucee.runtime.type.scope.Local local, lucee.runtime.type.scope.Argument arguments,
3542-
lucee.runtime.type.scope.Variables variables, PageSource pageSource, String functionName) {
3542+
DebuggerFrame(Local local, Argument arguments, Variables variables, PageSource pageSource, String functionName) {
35433543
this.local = local;
35443544
this.arguments = arguments;
35453545
this.variables = variables;
@@ -3558,8 +3558,7 @@ public static final class DebuggerFrame {
35583558
/**
35593559
* Push a new debugger frame onto the stack. Called on UDF entry when DEBUGGER is enabled.
35603560
*/
3561-
public void pushDebuggerFrame(lucee.runtime.type.scope.Local local, lucee.runtime.type.scope.Argument arguments,
3562-
lucee.runtime.type.scope.Variables variables, PageSource pageSource, String functionName, int startLine) {
3561+
public void pushDebuggerFrame(Local local, Argument arguments, Variables variables, PageSource pageSource, String functionName, int startLine) {
35633562
if (debuggerFrames != null) {
35643563
debuggerFrames.add(new DebuggerFrame(local, arguments, variables, pageSource, functionName));
35653564

@@ -3638,14 +3637,14 @@ public void debuggerSuspend(String label) {
36383637
}
36393638
else {
36403639
// Top-level code (outside functions) - try ExecutionLog's thread-local first
3641-
file = lucee.runtime.engine.DebuggerExecutionLog.getCurrentFile();
3642-
line = lucee.runtime.engine.DebuggerExecutionLog.getCurrentLine();
3640+
file = DebuggerExecutionLog.getCurrentFile();
3641+
line = DebuggerExecutionLog.getCurrentLine();
36433642

36443643
// Fall back to page source for file if thread-local not set
36453644
if (file == null) {
36463645
PageSource ps = getCurrentPageSource(null);
36473646
if (ps != null) {
3648-
lucee.commons.io.res.Resource res = ps.getPhyscalFile();
3647+
Resource res = ps.getPhyscalFile();
36493648
if (res != null) {
36503649
file = res.getAbsolutePath();
36513650
}
@@ -3746,11 +3745,6 @@ public long getDebuggerTotalSuspendedMillis() {
37463745

37473746
// ==================== End Debugger Stack Frame Support ====================
37483747

3749-
public FTPPoolImpl getFTPPool() {
3750-
if (ftpPool == null) ftpPool = new FTPPoolImpl();
3751-
return ftpPool;
3752-
}
3753-
37543748
/*
37553749
* *
37563750
*

core/src/main/java/lucee/runtime/config/ConfigAdmin.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
import lucee.commons.lang.ClassException;
7373
import lucee.commons.lang.ClassUtil;
7474
import lucee.commons.lang.ExceptionUtil;
75-
import lucee.commons.lang.PhysicalClassLoaderFactory;
7675
import lucee.commons.lang.StringUtil;
7776
import lucee.commons.net.HTTPUtil;
7877
import lucee.commons.net.IPRange;
@@ -1289,8 +1288,7 @@ public static void updateJar(Config config, Resource resJar, boolean reloadWhenC
12891288

12901289
// if there is an existing, has the file changed?
12911290
if (fileLib.length() != resJar.length()) {
1292-
PhysicalClassLoaderFactory.flush(config);
1293-
// IOUtil.closeEL(config.getClassLoader());
1291+
IOUtil.closeEL(config.getClassLoader());
12941292
ResourceUtil.copy(resJar, fileLib);
12951293
// NEXT if (reloadWhenClassicJar) ConfigUtil.reloadLib(config);
12961294
}
@@ -1712,7 +1710,8 @@ private void _removeJDBCDriver(ClassDefinition cd) throws PageException {
17121710
try {
17131711
OSGiUtil.uninstall(bl);
17141712
}
1715-
catch (BundleException e) {}
1713+
catch (BundleException e) {
1714+
}
17161715
}
17171716
}
17181717
}
@@ -1743,7 +1742,8 @@ private void _removeStartupHook(ClassDefinitionImpl cd) throws PageException {
17431742
try {
17441743
OSGiUtil.uninstall(bl);
17451744
}
1746-
catch (BundleException e) {}
1745+
catch (BundleException e) {
1746+
}
17471747
}
17481748
}
17491749
}
@@ -1778,7 +1778,8 @@ private void unloadStartupIfNecessary(ConfigPro config, ClassDefinition<?> cd, b
17781778
}
17791779
config.getStartups().remove(cd.getClassName());
17801780
}
1781-
catch (Exception e) {}
1781+
catch (Exception e) {
1782+
}
17821783
}
17831784

17841785
public void updateJDBCDriver(String label, String id, ClassDefinition cd, String connectionString) throws PageException {
@@ -1829,7 +1830,8 @@ private void _updateJDBCDriver(String label, String id, ClassDefinition cd, Stri
18291830
try {
18301831
OSGiUtil.uninstall(bl);
18311832
}
1832-
catch (BundleException e) {}
1833+
catch (BundleException e) {
1834+
}
18331835
}
18341836
}
18351837
}
@@ -5050,12 +5052,6 @@ else if (!StringUtil.isEmpty(cfc, true)) {
50505052
logger.error("extension", "Startup Hook from extension [" + rhext.getMetadata().getName() + ":" + rhext.getVersion()
50515053
+ "] could not be registered: class definition [" + cd + "] is not a valid OSGi bundle (missing bundle-name/bundle-version?) and no component specified");
50525054
}
5053-
// neither valid class nor component - log error
5054-
else {
5055-
logger.error("extension",
5056-
"Startup Hook from extension [" + rhext.getMetadata().getName() + ":" + rhext.getVersion() + "] could not be registered: class definition [" + cd
5057-
+ "] is not a valid OSGi bundle (missing bundle-name/bundle-version?) and no component specified");
5058-
}
50595055
}
50605056
}
50615057

@@ -6222,7 +6218,7 @@ private boolean _removeContext(Config config, String realpath, boolean _store) t
62226218
Resource context = config.getConfigDir().getRealResource("context");
62236219
Resource trg = context.getRealResource(realpath);
62246220
if (trg.exists()) {
6225-
LogUtil.log(config, Log.LEVEL_INFO, "deploy", "_removeContext() removing: " + trg.getAbsolutePath());
6221+
LogUtil.log( config, Log.LEVEL_INFO, "deploy", "_removeContext() removing: " + trg.getAbsolutePath() );
62266222
trg.remove(true);
62276223
if (_store) ConfigAdmin._storeAndReload((ConfigPro) config);
62286224
ResourceUtil.removeEmptyFolders(context, null);
@@ -6606,7 +6602,8 @@ public BundleDefinition[] _updateExtension(ConfigPro config, RHExtension ext) th
66066602
return old;
66076603
}
66086604
}
6609-
catch (Exception ee) {}
6605+
catch (Exception ee) {
6606+
}
66106607
}
66116608
}
66126609
catch (Exception e) {

core/src/main/java/lucee/runtime/engine/CFMLEngineImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
import lucee.runtime.config.ConfigWebImpl;
111111
import lucee.runtime.config.ConfigWebPro;
112112
import lucee.runtime.config.DeployHandler;
113+
import lucee.runtime.debug.DebuggerPrintStream;
113114
import lucee.runtime.config.Identification;
114115
import lucee.runtime.config.Password;
115116
import lucee.runtime.engine.listener.CFMLServletContextListener;
@@ -264,8 +265,8 @@ else if ("warn".equals(tmp) || "warning".equals(tmp)) {
264265
boolean debuggerEnabled = Caster.toBooleanValue(SystemUtil.getSystemPropOrEnvVar("lucee.debugger.enabled", null), false);
265266

266267
if (debuggerEnabled) {
267-
CONSOLE_OUT = new lucee.runtime.debug.DebuggerPrintStream(System.out, false);
268-
CONSOLE_ERR = new lucee.runtime.debug.DebuggerPrintStream(System.err, true);
268+
CONSOLE_OUT = new DebuggerPrintStream(System.out, false);
269+
CONSOLE_ERR = new DebuggerPrintStream(System.err, true);
269270
System.setOut(CONSOLE_OUT);
270271
System.setErr(CONSOLE_ERR);
271272
}

core/src/main/java/lucee/runtime/engine/DebuggerExecutionLog.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import java.util.Map;
44

5+
import lucee.commons.io.res.Resource;
56
import lucee.runtime.PageContext;
67
import lucee.runtime.PageContextImpl;
8+
import lucee.runtime.PageSource;
79
import lucee.runtime.debug.DebuggerListener;
810
import lucee.runtime.debug.DebuggerRegistry;
911

@@ -55,7 +57,10 @@ public void init(PageContext pc, Map<String, String> arguments) {
5557

5658
@Override
5759
public void start(int line, String id) {
58-
// pos is the line number when isLineBased() returns true
60+
// Early exit if no debugger connected - avoid all the work
61+
DebuggerListener listener = DebuggerRegistry.getListener();
62+
if (listener == null || !listener.isClientConnected()) return;
63+
5964
// Get file from debugger frame if available, otherwise from current page source
6065
String file = null;
6166
PageContextImpl.DebuggerFrame frame = pci.getTopmostDebuggerFrame();
@@ -65,9 +70,9 @@ public void start(int line, String id) {
6570
}
6671
else {
6772
// Top-level code (outside functions) - get file from page source
68-
lucee.runtime.PageSource ps = pci.getCurrentPageSource(null);
73+
PageSource ps = pci.getCurrentPageSource(null);
6974
if (ps != null) {
70-
lucee.commons.io.res.Resource res = ps.getPhyscalFile();
75+
Resource res = ps.getPhyscalFile();
7176
if (res != null) {
7277
file = res.getAbsolutePath();
7378
}
@@ -84,11 +89,8 @@ public void start(int line, String id) {
8489
}
8590

8691
// Check if debugger wants to suspend (breakpoint, stepping, etc.)
87-
if (file != null) {
88-
DebuggerListener listener = DebuggerRegistry.getListener();
89-
if (listener != null && listener.shouldSuspend(pci, file, line)) {
90-
pci.debuggerSuspend(file, line, null);
91-
}
92+
if (file != null && listener.shouldSuspend(pci, file, line)) {
93+
pci.debuggerSuspend(file, line, null);
9294
}
9395
}
9496

core/src/main/java/lucee/transformer/bytecode/BytecodeContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class BytecodeContext implements Context {
6464
private BytecodeContext root;
6565
private boolean writeLog;
6666
private Boolean isLineBased; // cached value, null = not yet calculated
67-
protected Set<Integer> executableLines = new TreeSet<>();
67+
protected Set<Integer> executableLines; // lazy init
6868
private int rtn = -1;
6969
private final boolean returnValue;
7070

@@ -282,6 +282,7 @@ public ConstrBytecodeContext getConstructor() {
282282

283283
public void visitLineNumber(int line) {
284284
this.line = line;
285+
if (executableLines == null) executableLines = new TreeSet<>();
285286
executableLines.add(line);
286287
// Also track in constructor context so getExecutableLines() gets all lines
287288
if (constr != null) {
@@ -295,6 +296,7 @@ public int getLine() {
295296
}
296297

297298
public int[] getExecutableLines() {
299+
if (executableLines == null) return new int[0];
298300
return executableLines.stream().mapToInt(Integer::intValue).toArray();
299301
}
300302

core/src/main/java/lucee/transformer/bytecode/ConstrBytecodeContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public List<Data> getUDFProperties() {
6363
public void trackExecutableLine(int line) {
6464
// Uses the executableLines Set inherited from BytecodeContext
6565
// We don't call visitLineNumber as that would emit bytecode
66+
if (super.executableLines == null) super.executableLines = new java.util.TreeSet<>();
6667
super.executableLines.add(line);
6768
}
6869

0 commit comments

Comments
 (0)