Skip to content

Avoid rescanning names for cached function lookups - #1525

Closed
2748109647 wants to merge 1 commit into
spring-cloud:mainfrom
2748109647:codex/issue-1518-cache-known-function-definitions
Closed

2748109647 wants to merge 1 commit into
spring-cloud:mainfrom
2748109647:codex/issue-1518-cache-known-function-definitions

Conversation

@2748109647

Copy link
Copy Markdown
Contributor

Fixes #1518

Message-level routing calls FunctionCatalog.lookup for every message. Before checking the wrapped-function cache, SimpleFunctionRegistry.normalizeFunctionDefinition enumerated function names; with the Spring-aware registry, this triggers repeated getBeanNamesForType scans.

The lookup now checks the synchronized wrapper cache and already registered function names before enumerating the full catalog. Unknown definitions still use the existing name-enumeration and single-function fallback path. No public API changes.

A regression test routes the same message twice and verifies the second lookup does not call getNames(null).

Validation:

  • .\mvnw.cmd -pl spring-cloud-function-context "-Dtest=BeanFactoryAwareFunctionRegistryTests,SimpleFunctionRegistryTests" -DfailIfNoTests=false test — BUILD SUCCESS; 89 tests, 0 failures, 0 errors, 3 skipped (Java 21).
  • git diff --check — passed.

@olegz

olegz commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution, the change looks good.

Could you please sign off your commit under the Developer Certificate of Origin? You can do that with:

git commit --amend -s --no-edit
git push --force-with-lease

so that the commit message ends with a Signed-off-by: Your Name <your-email> line. Once that is in place we can merge it.

Signed-off-by: Alpha <2748109647@qq.com>
@2748109647
2748109647 force-pushed the codex/issue-1518-cache-known-function-definitions branch from 07b27eb to b97ac17 Compare November 22, 2026 09:13
olegz pushed a commit that referenced this pull request Nov 22, 2026
Resolves #1518
Resolves #1525

Signed-off-by: Alpha <2748109647@qq.com>
Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
olegz added a commit that referenced this pull request Nov 22, 2026
… lookups

Use String.replace(char, char) instead of a regex based replaceAll when
normalizing function definitions, and add a SimpleFunctionRegistry
level test verifying that looking up an already resolved definition,
in its comma or pipe form, does not enumerate the function names again.

Resolves #1525

Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
olegz added a commit that referenced this pull request Nov 22, 2026
… function names

normalizeFunctionDefinition() replaces the requested definition with the
only eligible function when single function fallback is enabled, but only
if the definition is not one of the known function names. The shortcut for
definitions that are already cached or registered does not cover names that
exist as beans and are not registered yet, such as functionRouter, so the
lookup of functionRouter was turned into a lookup of the only other
function and HTTP requests to it were rejected by the method allow-list.

Check the known names again before applying the fallback and add a test.

Resolves #1525

Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
@olegz olegz closed this in 45dfc9d Nov 22, 2026
zemiles pushed a commit to zemiles/spring-cloud-function that referenced this pull request Nov 24, 2026
… test cached lookups

Use String.replace(char, char) instead of a regex based replaceAll when
normalizing function definitions, and add a SimpleFunctionRegistry
level test verifying that looking up an already resolved definition,
in its comma or pipe form, does not enumerate the function names again.

Resolves spring-cloud#1525

Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
zemiles pushed a commit to zemiles/spring-cloud-function that referenced this pull request Nov 24, 2026
…ack to known function names

normalizeFunctionDefinition() replaces the requested definition with the
only eligible function when single function fallback is enabled, but only
if the definition is not one of the known function names. The shortcut for
definitions that are already cached or registered does not cover names that
exist as beans and are not registered yet, such as functionRouter, so the
lookup of functionRouter was turned into a lookup of the only other
function and HTTP requests to it were rejected by the method allow-list.

Check the known names again before applying the fallback and add a test.

Resolves spring-cloud#1525

Signed-off-by: Oleg Zhurakousky <oleg.zhurakousky@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function-name resolution on every lookup

2 participants