Log exception when KeyValueDelegate.getMountInfo(…) fails.

Closes gh-888
This commit is contained in:
Mark Paluch
2025-04-25 11:50:11 +02:00
parent 015ae2e667
commit ee23af8ba0

View File

@@ -20,6 +20,9 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.StringUtils;
@@ -40,6 +43,8 @@ import org.springframework.vault.support.VaultResponse;
*/
public class KeyValueDelegate {
private static final Log logger = LogFactory.getLog(KeyValueDelegate.class);
private final Map<String, MountInfo> mountInfo;
private final VaultOperations operations;
@@ -125,13 +130,20 @@ public class KeyValueDelegate {
if (mountInfo == null) {
try {
mountInfo = doGetMountInfo(path);
}
catch (VaultException e) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to determine mount information for [%s]. Returning unavailable MountInfo: %s"
.formatted(path, e.getMessage()), e);
}
return MountInfo.unavailable();
}
catch (RuntimeException e) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to determine mount information for [%s]. Caching unavailable MountInfo: %s"
.formatted(path, e.getMessage()), e);
}
mountInfo = MountInfo.unavailable();
}