Skip to content

Commit

Permalink
add null check to StatsCollector os.getProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Dec 10, 2023
1 parent 6edb769 commit 83fd06a
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class StatsCollector(val socketServer: SocketServer) {
private val processRecentCpuUsage: Double
get() {
val p = os.getProcess(os.processId)
if (p == null) {
log.warn("Failed to get process stats. Process was null.")
return 0.0
}

val output: Double = if (cpuTime != 0.0) {
val uptimeDiff = p.upTime - uptime
Expand Down

0 comments on commit 83fd06a

Please sign in to comment.