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

NullPointerException in RepeatTemplate#doHandle() when unwrapIfRethrown() returns null if logging in DEBUG #1123

Closed
spring-projects-issues opened this issue Feb 24, 2016 · 0 comments
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: infrastructure type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Cyril Dejonghe opened BATCH-2479 and commented

I'm facing a case where unwrapIfRethrown() returns null (initial exception with no cause) :

/**
 * Unwraps the throwable if it has been wrapped by
 * {@link #rethrow(Throwable)}.
 */
	private static Throwable unwrapIfRethrown(Throwable throwable) {
		if (throwable instanceof RepeatException) {
			return throwable.getCause();
		}
		else {
			return throwable;
		}
	}

This causes doHandle() to fail :

	private void doHandle(Throwable throwable, RepeatContext context, Collection<Throwable> deferred) {
		// An exception alone is not sufficient grounds for not continuing
		Throwable unwrappedThrowable = unwrapIfRethrown(throwable);
		try {
			...
			if (logger.isDebugEnabled()) {
				logger.debug("Handling exception: " + throwable.getClass().getName() + ", caused by: " + unwrappedThrowable.getClass().getName() + ": " + unwrappedThrowable.getMessage());
			}
			exceptionHandler.handleException(context, unwrappedThrowable);

		} catch (Throwable handled) {
			deferred.add(handled);
		}
	}

The cause seem pretty clear : calling unwrappedThrowable.getClass().getName() + ": " + unwrappedThrowable.getMessage() on a null object ...


Affects: 3.0.6

@fmbenhassine fmbenhassine removed the status: waiting-for-triage Issues that we did not analyse yet label Nov 20, 2023
@fmbenhassine fmbenhassine added this to the 5.1.0 milestone Nov 20, 2023
@fmbenhassine fmbenhassine added for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line labels Nov 20, 2023
@fmbenhassine fmbenhassine changed the title RepeatTemplate#doHandle() throws NullPointerException when unwrapIfRethrown() returns null if logging in DEBUG [BATCH-2479] NullPointerException in RepeatTemplate#doHandle() when unwrapIfRethrown() returns null if logging in DEBUG Nov 20, 2023
fmbenhassine added a commit that referenced this issue Nov 20, 2023
Resolves #1123

(cherry picked from commit 03d2833)
fmbenhassine added a commit that referenced this issue Nov 20, 2023
Resolves #1123

(cherry picked from commit 03d2833)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-4.3.x Issues that will be back-ported to the 4.3.x line for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: infrastructure type: bug
Projects
None yet
Development

No branches or pull requests

2 participants