Events emitted twice
Closed this issue · 2 comments
RuudGianesini commented
Describe the bug
Event seems to be emitted twice.
To Reproduce
- Configure a new project using a filesystem storage
- Write a very simple event handler like this:
@Component
@StoreEventHandler
public class PocFileContentStoreEventHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PocFileContentStoreEventHandler.class);
@HandleAfterGetResource
public void handleAfterGetResource(PocFile pocFile) {
LOGGER.debug("PocFile {} resource has been fetched", pocFile.getId());
}
}
and an API with these rows:
LOGGER.debug(pocFile.getId());
pocFileContentStore.getResource(pocFile);
- call the API
- here's the output:
2024-03-21T10:37:39.271+01:00 DEBUG 7672 --- [Spring Content Poc] [nio-8080-exec-2] i.i.s.api.FileApiDelegateImpl : 14
2024-03-21T10:37:39.397+01:00 DEBUG 7672 --- [Spring Content Poc] [nio-8080-exec-2] i.i.s.c.PocFileContentStoreEventHandler : PocFile 14 resource has been fetched
2024-03-21T10:37:39.399+01:00 DEBUG 7672 --- [Spring Content Poc] [nio-8080-exec-2] i.i.s.c.PocFileContentStoreEventHandler : PocFile 14 resource has been fetched
Expected behavior
One row only wrote for PocFileContentStoreEventHandler class.
paulcwarren commented
Thanks @RuudGianesini , I'll take a look as soon as I can
paulcwarren commented
OK. I see the issue. It's to do with the compatibility layer that I put in to support the old org.springframework.content.commons.repository.ContentStore
interface alongside the newer org.springframework.content.commons.store.ContentStore
.
I have identified a pretty simple fix. Shouldn't take too long.