Skip to content

Commit

Permalink
Merge pull request #755 from jglick/CpsThreadDumpAction
Browse files Browse the repository at this point in the history
`…/threadDump/program.xml` hangs when program still loading pickles
  • Loading branch information
jglick authored Jul 25, 2023
2 parents 904c2ea + 6730402 commit 85ce2ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
*/
public final class CpsThreadDump {

/**
* Whether this is an actual list of threads, or just some special text such as a list of pickles.
*/
public final boolean valid;
private final List<ThreadInfo> threads = new ArrayList<>();

public static final class ThreadInfo {
Expand Down Expand Up @@ -103,7 +107,8 @@ public String toString() {
/**
* Use one of the {@link #from(CpsThreadGroup)} method.
*/
private CpsThreadDump() {
private CpsThreadDump(boolean valid) {
this.valid = valid;
}

public List<ThreadInfo> getThreads() {
Expand All @@ -128,7 +133,7 @@ public String toString() {
}

public static CpsThreadDump from(Throwable t) {
CpsThreadDump td = new CpsThreadDump();
CpsThreadDump td = new CpsThreadDump(false);
td.threads.add(new ThreadInfo(t));
return td;}

Expand All @@ -140,7 +145,7 @@ public static CpsThreadDump from(CpsThreadGroup g) {
l.add(t);
}

CpsThreadDump td = new CpsThreadDump();
CpsThreadDump td = new CpsThreadDump(true);
for (List<CpsThread> e : m.values())
td.threads.add(new ThreadInfo(e));
return td;
Expand All @@ -165,7 +170,7 @@ public static CpsThreadDump from(CpsThreadGroup g) {
/**
* Constant that indicates everything is done and no thread is alive.
*/
public static final CpsThreadDump EMPTY = new CpsThreadDump();
public static final CpsThreadDump EMPTY = new CpsThreadDump(false);

@Deprecated
public static final CpsThreadDump UNKNOWN = fromText("Program state is not yet known");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public String getParentUrl() throws IOException {
return execution.getThreadDump();
}

public String getThreadDump() {
return execution.getThreadDump().toString();
public CpsThreadDump getThreadDump() {
return execution.getThreadDump();
}

@WebMethod(name = "program.xml") public void doProgramDotXml(StaplerRequest req, StaplerResponse rsp) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@
<l:layout title="${%Thread Dump}" type="one-column">
<l:main-panel>
<j:set var="td" value="${it.threadDump}"/>
<j:set var="tds" value="${td.toString()}"/>

<h1>
${%Thread Dump}
<l:copyButton text="${td}" message="${%Thread dump copied to clipboard}"/>
<l:copyButton text="${tds}" message="${%Thread dump copied to clipboard}"/>
</h1>

<pre class="console">
${td}
${tds}
</pre>

<l:hasPermission permission="${app.RUN_SCRIPTS}">
<a href="program.xml">Serialized program state</a>
</l:hasPermission>
<j:if test="${td.valid}">
<l:hasPermission permission="${app.RUN_SCRIPTS}">
<a href="program.xml">Serialized program state</a>
</l:hasPermission>
</j:if>
</l:main-panel>
</l:layout>
</j:jelly>

0 comments on commit 85ce2ac

Please sign in to comment.