Skip to content

Conversation

@robocanic
Copy link
Contributor

Please provide a description of this PR:
gorm store need to add indexer before rebuilding indexes in the Init() method, while the memory store adds indexers after init. So the indexers initialization is assigned to each component-implemention to do.

To help us figure out who should review this PR, please put an X in all the areas that this PR affects.

  • Docs
  • Installation
  • User Experience
  • Dubboctl
  • Console
  • Core Component

Please check any characteristics that apply to this pull request.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a null pointer exception (NPE) issue by ensuring indexers are registered before store initialization. The GORM store requires indexers to be set up before calling rebuildIndices() during initialization, while the memory store was previously adding indexers after init. The solution moves indexer initialization responsibility from the central component to each store implementation.

  • Refactored indexer registration to occur within each store's Init() method instead of in the central store component
  • Modified NewMemoryResourceStore to accept a ResourceKind parameter for indexer lookup during initialization
  • Updated IndexersRegistry().Indexers() to return an empty map instead of nil for better null-safety

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/store/memory/store.go Added ResourceKind field and retrieves indexers during Init to pass to cache.NewIndexer
pkg/store/memory/factory.go Updated factory to pass ResourceKind parameter to NewMemoryResourceStore
pkg/store/dbcommon/gorm_store.go Added indexer registration in Init before rebuildIndices to fix NPE
pkg/core/store/index/registry.go Changed Indexers() to return empty map instead of nil with added documentation
pkg/core/store/component.go Removed indexer registration logic that was previously done after store Init

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

@robocanic robocanic merged commit cc7b273 into apache:develop Dec 20, 2025
5 checks passed
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.

1 participant