diff --git a/src/main/java/com/datapipe/jenkins/vault/credentials/AbstractVaultTokenCredentialWithExpiration.java b/src/main/java/com/datapipe/jenkins/vault/credentials/AbstractVaultTokenCredentialWithExpiration.java index 0cf695fe..cb330c87 100644 --- a/src/main/java/com/datapipe/jenkins/vault/credentials/AbstractVaultTokenCredentialWithExpiration.java +++ b/src/main/java/com/datapipe/jenkins/vault/credentials/AbstractVaultTokenCredentialWithExpiration.java @@ -44,13 +44,14 @@ public void setUsePolicies(Boolean usePolicies) { this.usePolicies = usePolicies; } - private transient Map tokenExpiry; + // Renamed from tokenExpiry to prevent XStream from attempting to deserialize old instances of this class which had the type `Calendar` prior to https://github.com/jenkinsci/hashicorp-vault-plugin/pull/223. + private transient Map tokenExpiryCache; private transient Map tokenCache; protected AbstractVaultTokenCredentialWithExpiration(CredentialsScope scope, String id, String description) { super(scope, id, description); - tokenExpiry = new HashMap<>(); + tokenExpiryCache = new HashMap<>(); tokenCache = new HashMap<>(); } @@ -108,7 +109,7 @@ public Vault authorizeWithVault(VaultConfig config, List policies) { // Upgraded instances can have these not initialized in the constructor (serialized jobs possibly) if (tokenCache == null) { tokenCache = new HashMap<>(); - tokenExpiry = new HashMap<>(); + tokenExpiryCache = new HashMap<>(); } String cacheKey = getCacheKey(policies); @@ -150,11 +151,11 @@ private void setTokenExpiry(Vault vault, String cacheKey) { } Calendar expiry = Calendar.getInstance(); expiry.add(Calendar.SECOND, tokenTTL); - tokenExpiry.put(cacheKey, expiry); + tokenExpiryCache.put(cacheKey, expiry); } private boolean tokenExpired(String cacheKey) { - Calendar expiry = tokenExpiry.get(cacheKey); + Calendar expiry = tokenExpiryCache.get(cacheKey); if (expiry == null) { return true; }