chinabugotech/hutool · error · IllegalStateException
Can't stop StopWatch: it's not running
Error message
Can't stop StopWatch: it's not running
What it means
Error "Can't stop StopWatch: it's not running" thrown in chinabugotech/hutool.
Source
Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:170
* @param taskName 新开始的任务名称
* @throws IllegalStateException 前一个任务没有结束
*/
public void start(String taskName) throws IllegalStateException {
if (null != this.currentTaskName) {
throw new IllegalStateException("Can't start StopWatch: it's already running");
}
this.currentTaskName = taskName;
this.startTimeNanos = System.nanoTime();
}
/**
* 停止当前任务
*
* @throws IllegalStateException 任务没有开始
*/
public void stop() throws IllegalStateException {
if (null == this.currentTaskName) {
throw new IllegalStateException("Can't stop StopWatch: it's not running");
}
final long lastTime = System.nanoTime() - this.startTimeNanos;
final long safeLastTime = Math.max(0, lastTime);
this.totalTimeNanos += safeLastTime;
this.lastTaskInfo = new TaskInfo(this.currentTaskName, safeLastTime);
if (null != this.taskList) {
this.taskList.add(this.lastTaskInfo);
}
++this.taskCount;
this.currentTaskName = null;
}
/**
* 检查是否有正在运行的任务
*
* @return 是否有正在运行的任务
* @see #currentTaskName()View on GitHub (pinned to 8870454b2a)
Solutions
- Call start() before stop(); ensure the StopWatch is running.
- Guard with isRunning() before calling stop().
When it happens
Trigger: Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:170 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chinabugotech/hutool@8870454b2a (2026-08-14).
Data as JSON: /api/errors/ee60d095ae0c48ee.
Report an issue: GitHub.