Skip to content

[codex] Fix AI SPI classloader fallback#4242

Closed
kobewl wants to merge 1 commit intochinabugotech:v5-devfrom
kobewl:codex/fix-ai-spi-classloader
Closed

[codex] Fix AI SPI classloader fallback#4242
kobewl wants to merge 1 commit intochinabugotech:v5-devfrom
kobewl:codex/fix-ai-spi-classloader

Conversation

@kobewl
Copy link
Copy Markdown

@kobewl kobewl commented Apr 3, 2026

Summary

  • load AI SPI implementations from the thread context class loader first, then fall back to the SPI interface class loader
  • apply the same fallback behavior to both AIServiceFactory and AIConfigRegistry`n- add regression tests that simulate a context class loader which cannot see the SPI resources

Root cause

ServiceLoader was only using the current thread context class loader. In thread-pool or Spring-style execution environments, that loader may not be able to resolve META-INF/services, which leaves the AI provider/config registries empty and causes Unsupported model errors.

Validation

  • mvn -pl hutool-ai -am -Dsurefire.failIfNoSpecifiedTests=false -Dtest=AISpiClassLoaderCompatibilityTest,AIServiceFactoryTest test (run with JDK 8)

@looly looly changed the base branch from v5-master to v5-dev April 7, 2026 02:17
@looly looly closed this Apr 7, 2026
@looly
Copy link
Copy Markdown
Collaborator

looly commented Apr 7, 2026

这块乱码了,我手动修复了。

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.

2 participants