gnodet commented on code in PR #27679:
URL: https://github.com/apache/camel/pull/27679#discussion_r4240655688
##########
components/camel-hashicorp-vault/src/main/java/org/apache/camel/component/hashicorp/vault/HashicorpVaultPropertiesFunction.java:
##########
@@ -247,11 +257,14 @@ private String getSecretFromSource(String key, String
subkey, String defaultValu
}
}
if (ObjectHelper.isNotEmpty(subkey)) {
- Object field = ((Map)
rawSecret.getData().get("data")).get(subkey);
- if (ObjectHelper.isNotEmpty(field)) {
- returnValue = field.toString();
- } else {
- returnValue = null;
+ returnValue = null;
+ // the secret may not exist, then there is no field either
+ if (rawSecret != null && rawSecret.getData() != null
+ && rawSecret.getData().get("data") instanceof Map<?,
?> data) {
+ Object field = data.get(subkey);
+ if (ObjectHelper.isNotEmpty(field)) {
+ returnValue = field.toString();
+ }
}
}
if (ObjectHelper.isEmpty(returnValue)) {
Review Comment:
💡 **Minor: inconsistent null-safety between subkey and non-subkey paths.**
The subkey path (this block) now correctly guards against `null` from
`rawSecret`, `getData()`, and `getData().get("data")`. A few lines above, the
non-subkey path still calls `rawSecret.getData().get("data").toString()`
without those guards — pre-existing, but inconsistent now that this block is
hardened. Worth addressing in a follow-up for completeness.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]