Skip to content

Commit db43daa

Browse files
committed
code cleanup
- remove redundant parenthesis, reduce code indentation - utils function -> util functions
1 parent ee71655 commit db43daa

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

find-in-jars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ else
144144
fi
145145

146146
################################################################################
147-
# utils
147+
# util funtions
148148
################################################################################
149149

150150
[ -t 1 ] && readonly is_console=true || readonly is_console=false

parseOpts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# @author Jerry Lee (oldratlee at gmail dot com)
2020

2121
#####################################################################
22-
# Utils Funtions
22+
# Util Funtions
2323
#####################################################################
2424

2525
# NOTE: $'foo' is the escape sequence syntax of bash

show-busy-java-threads

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ readonly -a COMMAND_LINE=("$0" "$@")
1717
readonly USER="`whoami`"
1818

1919
################################################################################
20-
# utils funtions
20+
# util funtions
2121
################################################################################
2222

2323
# NOTE: $'foo' is the escape sequence syntax of bash
@@ -190,22 +190,20 @@ printStackOfThreads() {
190190
((counter++))
191191
local jstackFile=/tmp/${uuid}_${pid}
192192
[ -f "${jstackFile}" ] || {
193-
{
194-
if [ "${user}" == "${USER}" ]; then
195-
# run without sudo, when java process user is current user
196-
"$jstack_path" ${force} $mix_native_frames $more_lock_info ${pid} > ${jstackFile}
197-
elif [ $UID == 0 ]; then
198-
# if java process user is not current user, must run jstack with sudo
199-
sudo -u "${user}" "$jstack_path" ${force} $mix_native_frames $more_lock_info ${pid} > ${jstackFile}
200-
else
201-
# current user is not root user, so can not run with sudo; print error message and rerun suggestion
202-
redPrint "[$counter] Fail to jstack busy(${pcpu}%) thread(${threadId}/${threadId0x}) stack of java process(${pid}) under user(${user})."
203-
redPrint "User of java process($user) is not current user($USER), need sudo to rerun:"
204-
yellowPrint " sudo ${COMMAND_LINE[@]}"
205-
normalPrint
206-
continue
207-
fi
208-
} || {
193+
if [ "${user}" == "${USER}" ]; then
194+
# run without sudo, when java process user is current user
195+
"$jstack_path" ${force} $mix_native_frames $more_lock_info ${pid} > ${jstackFile}
196+
elif [ $UID == 0 ]; then
197+
# if java process user is not current user, must run jstack with sudo
198+
sudo -u "${user}" "$jstack_path" ${force} $mix_native_frames $more_lock_info ${pid} > ${jstackFile}
199+
else
200+
# current user is not root user, so can not run with sudo; print error message and rerun suggestion
201+
redPrint "[$counter] Fail to jstack busy(${pcpu}%) thread(${threadId}/${threadId0x}) stack of java process(${pid}) under user(${user})."
202+
redPrint "User of java process($user) is not current user($USER), need sudo to rerun:"
203+
yellowPrint " sudo ${COMMAND_LINE[@]}"
204+
normalPrint
205+
continue
206+
fi || {
209207
redPrint "[$counter] Fail to jstack busy(${pcpu}%) thread(${threadId}/${threadId0x}) stack of java process(${pid}) under user(${user})."
210208
normalPrint
211209
rm ${jstackFile}

test-cases/parseOpts-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BASE=`dirname $0`
66

77

88
#################################################
9-
# Utils Functions
9+
# Util Functions
1010
#################################################
1111

1212
# NOTE: $'foo' is the escape sequence syntax of bash

0 commit comments

Comments
 (0)