-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
Thomas Escolan opened SPR-13509 and commented
- The currentTaskName field is private (final) without a getter
The running task's name cannot be retrieved unless stop is called.
WORKAROUND
StopWatch sw = new StopWatch();
try {
Field f = StopWatch.class.getDeclaredField("currentTaskName");
f.setAccessible(true); // I'm a hacker!
String taskname = f.get(sw);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}- The start method runs init actions AFTER storing timestamp
ILLUSTRATION
public void start(String taskName) throws IllegalStateException {
if (this.running) {
throw new IllegalStateException("Can't start StopWatch: it's already running");
}
this.startTimeMillis = System.currentTimeMillis(); // to be done last...
this.running = true;
this.currentTaskName = taskName;
// ... there ; in order not to take inits above into account
}Affects: 4.1.7
Referenced from: commits a6a6aed
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement