This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Resolve ""Error: Exercise could not be found..." during resource loading"

Files
5
@@ -7,6 +7,7 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.audit.AuditEvent;
@@ -62,8 +63,9 @@ public class AuditEventService {
* This is scheduled to get fired at 11:00 (pm) UTC.
*/
@Scheduled(cron = "0 0 23 * * ?")
public void removeOldAuditEvents() {
public int removeOldAuditEvents() {
boolean next = true;
AtomicInteger count = new AtomicInteger(0);
while (next) {
next =
@@ -74,12 +76,14 @@ public class AuditEventService {
final List<PersistentAuditEvent> auditEventDeleteCandidates = persistenceAuditEventRepository.findTop1000ByAuditEventDateBefore(
Instant.now().minus(jHipsterProperties.getAuditEvents().getRetentionPeriod(), ChronoUnit.DAYS)
);
count.set(count.intValue() + auditEventDeleteCandidates.size());
persistenceAuditEventRepository.deleteAll(auditEventDeleteCandidates);
return !auditEventDeleteCandidates.isEmpty();
}
}
);
}
return count.intValue();
// not working, due to https://hibernate.atlassian.net/browse/HHH-5528
// int count = persistenceAuditEventRepository.deleteInBulkByRoleId(
// Instant.now().minus(jHipsterProperties.getAuditEvents().getRetentionPeriod(), ChronoUnit.DAYS)