You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "Aarti Panchal (Jira)" <ji...@apache.org> on 2026/10/21 17:01:00 UTC

[jira] [Commented] (FINERACT-2981) Hook lookup cache key ignores the event, so the wrong hooks fire when the single-node cache is enabled

    [ https://issues.apache.org/jira/browse/FINERACT-2981?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18129752#comment-18129752 ] 

Aarti Panchal commented on FINERACT-2981:
-----------------------------------------

PR: [https://github.com/apache/fineract/pull/6711]

 

> Hook lookup cache key ignores the event, so the wrong hooks fire when the single-node cache is enabled
> ------------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2981
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2981
>             Project: Apache Fineract
>          Issue Type: Bug
>            Reporter: Aarti Panchal
>            Priority: Major
>
> HookReadPlatformServiceImpl.retrieveHooksByEvent(entityName, actionName) is @Cacheable("hooks") with key = tenantIdentifier + 'HK'. Neither argument is in the key, so with an explicit key Spring caches one list per tenant, but HookRepository.findAllHooksListeningToEvent filters by entityName and actionName.
> FineractHookListener calls it after every write command (via SynchronousCommandProcessingService.publishHookEvent), so the first command in a tenant fills the cache and for the next minute (default TTL) every other event gets that same hook list:
> - hooks subscribed to event A fire for event B, with B's payload
> - hooks for B never fire
> - if the first command has no hooks, no hook fires for any event during that minute
> Only when the "hooks" cache is live, i.e. after switching to the single-node cache (PUT /v1/caches with cacheType 2). On the default no-op cache nothing is cached, which is why HookIntegrationTest and CI never see it.
> Example: hook A on CLIENT/CREATE, hook B on LOAN/APPROVE, single-node cache on. Create a client, then approve a loan within a minute: A fires for the loan approval, B does not.
> Fix: put the event in the key, e.g. getTenantIdentifier().concat('HK|' + #entityName + '|' + #actionName). The @CacheEvict(allEntries = true) on hook create/update/delete already clears all entries. A unit test with a ConcurrentMapCacheManager can show the second event currently gets the first event's hooks.
> Found while working on FINERACT-2974 (hook update).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)