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?
| @Test | ||
| @Disabled | ||
| void executeWithRealVault() { | ||
| // setup.setVaultUrl("http://localhost:8200"); |
There was a problem hiding this comment.
It's fishy...
Was it AI that modified that test (even so it's Disabled)?
| throwError.setAccessible(true); | ||
| try { | ||
| throwError.invoke(vaultClient, waeWithoutResponse); | ||
| org.junit.jupiter.api.Assertions.fail("Expected a WebApplicationException to be thrown"); |
There was a problem hiding this comment.
please import this 'org.junit.jupiter.api.Assertions'
| final VaultClient vaultClient = new VaultClient(); | ||
| final java.lang.reflect.Field f = VaultClient.class.getDeclaredField("shouldRetry"); | ||
| f.setAccessible(true); | ||
| final java.util.function.Predicate<Throwable> shouldRetry = |
There was a problem hiding this comment.
we don't need this predicate...
There was a problem hiding this comment.
just call this function directly inside

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