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

Errors from a MethodInvokingJob are only logged at WARN/INFO level (and twice...) [SPR-4630] #9307

Closed
spring-projects-issues opened this issue Mar 26, 2008 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Martin Probst opened SPR-4630 and commented

When a MethodInvokingJob scheduled by Quartz throws an exception, the error is logged twice, once at WARN level by the MethodInvokingJob wrapper, and once at INFO by Quartz.

This is because the MethodInvokingJob catches all exceptions thrown by the invoked method (InvocationTargetExceptions), and then re-throws them as JobExecutionExceptions. Quartz apparently considers those to be "expected exceptions" that are used for scheduling purposes, and as such they are only logged as INFO.

Spring's MethodInvokingJob should probably find out if the thrown exceptions was a runtime exception, and re-throw it, and simply wrap checked exceptions in an appropriate RuntimeException and rethrow them. JobExecutionExceptions are apparently reserved for other purposes.

Also, you should probably not log an exception that you are re-throwing anyways, that only gives duplicate log entries, making a potential problem harder to find.


Affects: 2.0.8, 2.5.1

Backported to: 2.0.9

@spring-projects-issues
Copy link
Collaborator Author

Martin Probst commented

Of course this is your decision, but I intentionally marked this as a bug. With this behaviour, errors that happen in scheduled tasks will not get logged in many production environments, and will not cause e.g. error emails being sent. That is IMHO a bug, and it might even be quite nasty with errors going unnoticed.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Agreed - you've got a point there.

I'm also scheduling this for a fix in the Spring 2.0 maintenance branch.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've revised MethodInvokingJob to rethrow invocation exceptions as JobMethodInvocationFailedException (a custom RuntimeException), triggering error logging by Quartz. MethodInvokingJob does not perform own warn logging there anymore. I've also revised DelegatingJob and MethodInvokingRunnable accordingly, for consistent error level logging.

This will be available in tonight's 2.5.3 snapshot (http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it a try and let me know whether it works for you...

As for the 2.0.9 release, I've only raised MethodInvokingJob's own log level to error there while still throwing JobExecutionExceptions. The reasoning there is as little impact on existing usage as possible, which doesn't allow for changing to a different type of Quartz exception. So there will still be double logging on 2.0.9 but at least one of them is at error level...

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 2.5.3 milestone Jan 11, 2019
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) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants