Skip to content

Add getLastTask() method to o.sf.util.StopWatch (and fix a couple of typos) [SPR-7134] #11793

@spring-projects-issues

Description

@spring-projects-issues

Richard Fearn opened SPR-7134 and commented

It would be handy to have a getLastTask() method to allow the TaskInfo object to be passed around (e.g. for logging). Something like this:

/**
 * Return the last task.
 */
public TaskInfo getLastTask() throws IllegalStateException {
	if (this.lastTaskInfo == null) {
		throw new IllegalStateException("No tasks run: can't get last task");
	}
	return this.lastTaskInfo;
}

Also, there's a typo in getLastTaskName(), presumably because getLastTaskTimeMillis() was copied. The exception message should read "can't get last name" instead of "can't get last interval".

Finally, I imagine this has something to do with the original use of this code, but shouldn't the execption messages in both getLastTaskName() and getLastTaskTimeMillis() refer to "tasks" instead of "tests"?


Affects: 3.0.2

Referenced from: commits ceb668a

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions