Repository navigation
Conversation
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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes gh-19935.
doExecuteSubject()threwRestClientException("doExecute returned null")wheneverRestTemplate.doExecute()returned null. That null is legitimate: the response extractor may return null, anddelete()/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 throughdoExecuteSubject(), thedoExecute()override and thePrivilegedActionlambda instead of being narrowed.A regression test (
deleteWithNoContentSucceeds) drivesKerberosRestTemplate.delete()against an endpoint returning 204 No Content through the existing MiniKdc + MockWebServer setup; it fails withRestClientException: doExecute returned nullbefore the change and passes after. FullKerberosRestTemplateTests(3 tests) passes.