diff --git a/src/main/java/org/dependencytrack/tasks/NistApiMirrorTask.java b/src/main/java/org/dependencytrack/tasks/NistApiMirrorTask.java index 38377bd922..2feddbd9f1 100644 --- a/src/main/java/org/dependencytrack/tasks/NistApiMirrorTask.java +++ b/src/main/java/org/dependencytrack/tasks/NistApiMirrorTask.java @@ -395,7 +395,7 @@ private static boolean updateLastModified(final ZonedDateTime lastModifiedDateTi } LOGGER.debug("Latest captured modification date: %s".formatted(lastModifiedDateTime)); - try (final var qm = new QueryManager().withL2CacheDisabled()) { + try (final var qm = new QueryManager()) { qm.runInTransaction(() -> { final ConfigProperty property = qm.getConfigProperty( VULNERABILITY_SOURCE_NVD_API_LAST_MODIFIED_EPOCH_SECONDS.getGroupName(), diff --git a/src/test/java/org/dependencytrack/tasks/NistApiMirrorTaskTest.java b/src/test/java/org/dependencytrack/tasks/NistApiMirrorTaskTest.java index b7e4cb13ea..a10169f6d0 100644 --- a/src/test/java/org/dependencytrack/tasks/NistApiMirrorTaskTest.java +++ b/src/test/java/org/dependencytrack/tasks/NistApiMirrorTaskTest.java @@ -18,6 +18,7 @@ */ package org.dependencytrack.tasks; +import alpine.model.ConfigProperty; import com.github.tomakehurst.wiremock.junit.WireMockRule; import org.dependencytrack.PersistenceCapableTest; import org.dependencytrack.event.NistApiMirrorEvent; @@ -233,6 +234,16 @@ public void testInformWithNewVulnerability() throws Exception { assertThat(qm.hasAffectedVersionAttribution(vuln, vs, Source.NVD)).isTrue(); } ); + + // Property is in L1 cache because it was created in the test's setUp method. + // Evict L1 cache to reach L2 cache / datastore instead. + qm.getPersistenceManager().evictAll(); + final ConfigProperty lastModifiedProperty = qm.getConfigProperty( + VULNERABILITY_SOURCE_NVD_API_LAST_MODIFIED_EPOCH_SECONDS.getGroupName(), + VULNERABILITY_SOURCE_NVD_API_LAST_MODIFIED_EPOCH_SECONDS.getPropertyName() + ); + assertThat(lastModifiedProperty).isNotNull(); + assertThat(lastModifiedProperty.getPropertyValue()).isEqualTo("1691504544"); } @Test