Skip to content

Fix KerberosRestTemplate failing successful calls that return no body - #19936

Open
Lyin-OTTF wants to merge 1 commit into
spring-projects:mainfrom
Lyin-OTTF:fix/gh-19935-kerberos-rest-template-null
Open

Lyin-OTTF wants to merge 1 commit into
spring-projects:mainfrom
Lyin-OTTF:fix/gh-19935-kerberos-rest-template-null

Conversation

@Lyin-OTTF

Copy link
Copy Markdown

Closes gh-19935.

doExecuteSubject() threw RestClientException("doExecute returned null") whenever RestTemplate.doExecute() returned null. That null is legitimate: the response extractor may return null, and delete()/put() run without an extractor, so a successful HTTP 204 No Content surfaced as an exception - exactly as described in the issue.

The fix lets the null pass through. Since RestTemplate.doExecute() is declared <T> @Nullable T, the nullability now propagates through doExecuteSubject(), the doExecute() override and the PrivilegedAction lambda instead of being narrowed.

A regression test (deleteWithNoContentSucceeds) drives KerberosRestTemplate.delete() against an endpoint returning 204 No Content through the existing MiniKdc + MockWebServer setup; it fails with RestClientException: doExecute returned null before the change and passes after. Full KerberosRestTemplateTests (3 tests) passes.

doExecuteSubject() threw RestClientException("doExecute returned null")
whenever RestTemplate.doExecute() returned null. That null is legitimate:
the response extractor may return null, and delete()/put() run without an
extractor, so a successful HTTP 204 No Content surfaced as an exception.

Let the null pass through. RestTemplate.doExecute() is declared
@nullable, so doExecuteSubject(), the doExecute() override and the
PrivilegedAction now propagate nullability instead of narrowing it.

Closes spring-projectsgh-19935

Signed-off-by: Lyin-OTTF <htao08203@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KerberosRestTemplate throws RestClientException when doExecute() returns null

2 participants