Skip to content

Commit 5dcacfa

Browse files
author
Alagappan21
committed
Sai: Changing first attempt to collect thread dump using jattach
1 parent 2260aab commit 5dcacfa

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

internal/capture/jstack.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@ func (t *JStack) Run() (result Result, err error) {
6363
outputFileName := fmt.Sprintf("javacore.%d.out", n)
6464
var jstackFile *os.File = nil
6565

66-
// Thread dump: Attempt 1: jstack
67-
if jstackFile == nil {
68-
logger.Log("Trying to capture thread dump using jstack ...")
69-
jstackFile, err = executils.CommandCombinedOutputToFile(
70-
outputFileName,
71-
executils.Command{path.Join(t.javaHome, "bin/jstack"), "-l", strconv.Itoa(t.pid)},
72-
executils.SudoHooker{PID: t.pid},
73-
)
74-
if err != nil {
75-
logger.Log("Failed to run jstack with err %v", err)
76-
}
77-
}
7866
// Thread dump: Attempt 2a: jattach via self execution with -tdCaptureMode
7967
if jstackFile == nil {
8068
logger.Log("Trying to capture thread dump using jattach...")
@@ -99,7 +87,20 @@ func (t *JStack) Run() (result Result, err error) {
9987
logger.Log("Failed to Copy2TempPath with err %v", err)
10088
}
10189
}
102-
90+
91+
// Thread dump: Attempt 1: jstack
92+
if jstackFile == nil {
93+
logger.Log("Trying to capture thread dump using jstack ...")
94+
jstackFile, err = executils.CommandCombinedOutputToFile(
95+
outputFileName,
96+
executils.Command{path.Join(t.javaHome, "bin/jstack"), "-l", strconv.Itoa(t.pid)},
97+
executils.SudoHooker{PID: t.pid},
98+
)
99+
if err != nil {
100+
logger.Log("Failed to run jstack with err %v", err)
101+
}
102+
}
103+
103104
// Thread dump: Attempt 5: jstack -F
104105
if jstackFile == nil {
105106
logger.Log("Trying to capture thread dump using jstack -F ...")

0 commit comments

Comments
 (0)