Skip to content

refactor(context): clean up ContextFunctionCatalogAutoConfiguration - #1431

Open
akenra wants to merge 1 commit into
spring-cloud:mainfrom
akenra:bugfix/gh-1421
Open

refactor(context): clean up ContextFunctionCatalogAutoConfiguration#1431
akenra wants to merge 1 commit into
spring-cloud:mainfrom
akenra:bugfix/gh-1421

Conversation

@akenra

@akenra akenra commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Hi @olegz!

This PR addresses the cleanup requested in #1421 along with a few error-handling and typing improvements in ContextFunctionCatalogAutoConfiguration.

A few details on what's inside:

  • I chained the MapperBuilder fluently using wildcard generics to get rid of raw type warnings, suppressions, and intermediate variables.
  • While digging through the Jackson and Gson setup, I noticed that context lookup failures were being swallowed silently before dropping back to defaults. I've added proper warning logs there.
  • Also, I have improved the Kotlin Jackson module reflection with explicit type/subclass checks so we can catch version mismatches or classloader conflicts instead of just ignoring a ClassNotFoundException.
  • The rest is just straightforward modernization and cosmetics: updated instanceof checks to use pattern matching, simplified the anonymous ContentTypeResolver into a null-safe lambda, and fixed a typo in the exception message.

Let me know if anything needs adjustments!

Fixes #1421

Addresses spring-cloud#1421 requested cleanups:
- Make logger private static final
- Inject FunctionProperties as a bean parameter in functionCatalog() instead of calling context.getBean()
- Cleanup unnecessary initializations

Additional improvements:
- Use wildcard MapperBuilder<?, ?> to fix unsafe raw type usage and clean up builder chaining
- Log detailed warning when ObjectMapper context lookup or .rebuild() fails before falling back to default builder
- Log warning on Gson context lookup failure prior to default fallback
- Make Kotlin module reflection type-safe via ClassUtils.forName(), isAssignableFrom(), and asSubclass(), adding warning logs for missing/incompatible modules
- Modernize casting using Java 17 pattern matching for ConversionService, CompositeMessageConverter, and CloudEventsFunctionInvocationHelper
- Simplify StringMessageConverter ContentTypeResolver to a null-safe lambda
- Explicitly pass ClassUtils.getDefaultClassLoader() to ClassUtils.isPresent() checks
- Fix typo in JsonMapper exception message ("claspath" -> "classpath")

Fixes spring-cloud#1421

Signed-off-by: akenra <37288280+akenra@users.noreply.github.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.

Clean up ContextFunctionCatalogAutoConfiguration

1 participant