Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve toString for reactive ScheduledTask #34010

Closed
slaha opened this issue Dec 3, 2024 · 2 comments
Closed

Improve toString for reactive ScheduledTask #34010

slaha opened this issue Dec 3, 2024 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@slaha
Copy link

slaha commented Dec 3, 2024

Hello,

There were some improvements in the actuator/scheduledtasks endpoint in SpringBoot 3.4 which are great but when the task is reactive (kotlin suspend function in my case but I think the same applies for reactor types), the task is wrapped in SubscribingRunnable and therefore the name of the task (in runnable.target) does not show the actual name of the task:

{
    "runnable": {
        "target": "org.springframework.scheduling.annotation.ScheduledAnnotationReactiveSupport$SubscribingRunnable@62658650"
    },
    "initialDelay": 1067,
    "interval": 120000,
    "nextExecution": {
        "time": "2024-12-02T20:26:46.714560Z"
    },
    "lastExecution": {
        "time": "2024-12-02T20:24:46.666944Z",
        "status": "SUCCESS"
    }
}

I checked the sources and it does not seem there is an easy way how to change the value. The SubscribingRunnable.toString is used. My suggestion is to override the toString method in SubscribingRunnable to show coordinates of the actual task method.

So TLDR:
Problem: Name of scheduled task in actuator/scheduledtasks is useless when task is wrapped in SubscribingRunnable
Desired state: The name is taken from the actual task class/method, not SubscribingRunnable.

SpringBoot version: 3.4.0

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 3, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Dec 3, 2024
@bclozel bclozel self-assigned this Dec 3, 2024
@bclozel bclozel added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 3, 2024
@bclozel bclozel added this to the 6.2.1 milestone Dec 3, 2024
@lucky8987
Copy link
Contributor

@bclozel Can this issue be assigned to me? I can submit a PR to fix it.

@Override
public String toString() {
	Method method = contextSupplier.get().getMethod();
	return method.getDeclaringClass().getName() + "." + method.getName();
}

@bclozel
Copy link
Member

bclozel commented Dec 3, 2024

Thanks for the proposal but it's already assigned.

@bclozel bclozel changed the title Name of reactive tasks in actuator/scheduledtasks Improve toString for reactive ScheduledTask Dec 3, 2024
@bclozel bclozel closed this as completed in d990449 Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants