Spring / Spring CredHub Interview questions
What happens when you call getByName for a credential that does not exist?
CredHub returns an HTTP 404, and Spring CredHub surfaces that as a CredHubException rather than returning null or an empty result — so calling code needs to catch it (or check existence some other way) rather than null-check the return value.
This trips up developers migrating from APIs that return Optional or null for a missing key: with Spring CredHub, a missing credential is an exceptional case, not a normal empty-result path.
In practice, code that needs to distinguish "credential is missing" from "CredHub is unreachable" typically wraps the call in a try/catch, inspects the exception's status code, and only treats a 404 as "not found," letting other statuses propagate as genuine failures.
More Related questions...