chinabugotech/hutool · error · IllegalStateException
Can't start StopWatch: it's already running
Error message
Can't start StopWatch: it's already running
What it means
Error "Can't start StopWatch: it's already running" thrown in chinabugotech/hutool.
Source
Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:157
/**
* 开始默认的新任务
*
* @throws IllegalStateException 前一个任务没有结束
*/
public void start() throws IllegalStateException {
start(StrUtil.EMPTY);
}
/**
* 开始指定名称的新任务
*
* @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;View on GitHub (pinned to 8870454b2a)
Solutions
- Call stop() before calling start() again on the same StopWatch.
- Create a new StopWatch instance for each measurement.
When it happens
Trigger: Thrown at hutool-core/src/main/java/cn/hutool/core/date/StopWatch.java:157 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/ba69ffd90e823ac8.
Report an issue: GitHub.