Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public synchronized void handleRecentResourceUpdate(
if (actualValues != null) {
var resourceId = resourceIDMapper.idFor(resource);
R actualResource = actualValues.get(resourceId);
if (actualResource.equals(previousVersionOfResource)) {
if (actualResource != null && actualResource.equals(previousVersionOfResource)) {
actualValues.put(resourceId, resource);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ void genericFilteringEvents() {
verify(eventHandler, times(0)).handleEvent(any());
}

@Test
void recentResourceUpdateIsIgnoredForUnknownSecondaryResource() {
source.handleResources(primaryID1(), Set.of(testResource1()));

// testResource2 has a different id, so it is not present in the cache for primaryID1
var unknown = testResource2();
source.handleRecentResourceUpdate(primaryID1(), unknown, unknown);

assertThat(source.getSecondaryResources(primaryID1())).containsExactly(testResource1());
}

public static class TestExternalCachingEventSource
extends ExternalResourceCachingEventSource<SampleExternalResource, HasMetadata, String> {
public TestExternalCachingEventSource() {
Expand Down
Loading