Navigation Menu

Skip to content

Commit

Permalink
oxcore : fixed bug with cache entity persistence with NativePersistence.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Aug 9, 2018
1 parent 7742b3b commit 1562941
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -116,12 +116,23 @@ public void put(String expirationInSeconds, String key, Object object) {
entity.setCreationDate(creationDate);
entity.setExpirationDate(expirationDate.getTime());

silentlyRemoveEntityIfExists(entity);
ldapEntryManager.persist(entity);
} catch (Exception e) {
log.trace("Failed to put entry, key: " + originalKey + ", hashedKey: " + key + ", message: " + e.getMessage(), e); // log as trace since it is perfectly valid that entry is removed by timer for example
}
}

private void silentlyRemoveEntityIfExists(NativePersistenceCacheEntity entity) {
try {
if (ldapEntryManager.find(NativePersistenceCacheEntity.class, entity.getDn()) != null) {
ldapEntryManager.removeWithSubtree(entity.getDn());
}
} catch (Exception e) {
// ignore
}
}

private static boolean isExpired(Date expiredAt) {
return expiredAt == null || expiredAt.before(new Date());
}
Expand Down

0 comments on commit 1562941

Please sign in to comment.