fix(QTDI-2954): fix possible NPE in VaultClient - #1230
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a possible null response handling issue in VaultClient.throwError(Throwable) by preserving the configured fallback status when a WebApplicationException has no Response.
Changes:
- Moves
response.getStatus()inside the existing null check inthrowError(Throwable). - Adds a unit test that invokes
throwError(Throwable)with aWebApplicationExceptionwhose response is null.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
vault-client/src/main/java/org/talend/sdk/components/vault/client/VaultClient.java |
Makes throwError(Throwable) avoid dereferencing a null JAX-RS response. |
vault-client/src/test/java/org/talend/sdk/components/vault/client/VaultClientTest.java |
Adds regression coverage for null response handling in throwError(Throwable). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Conflicts: # vault-client/src/main/java/org/talend/sdk/components/vault/client/VaultClient.java # vault-client/src/test/java/org/talend/sdk/components/vault/client/VaultClientTest.java
ozhelezniak-talend
left a comment
There was a problem hiding this comment.
okay
Could we rewrite the tests to not call private methods as units?
Maybe we can do component-test instead?
| }; | ||
|
|
||
| // Must not NPE, and must allow the retry loop to keep running (true = retry). | ||
| assertTrue(((Predicate<Throwable>) f.get(vaultClient)).test(waeWithoutResponse)); |
There was a problem hiding this comment.
can it be assertEquals?
There was a problem hiding this comment.
The result is the same with assertEquals and is more expressive with a predicate.
Any reason to prefer?

https://qlik-dev.atlassian.net/browse/QTDI-2954
Requirements
Why this PR is needed?
What does this PR adds (design/code thoughts)?
AI generated code
https://internal.qlik.dev/general/ways-of-working/code-reviews/#guidelines-for-ai-generated-code