Skip to content

[Hotfix][ams] Fix ResourceMapper.selectResourcesByGroup result mapping#4194

Merged
zhoujinsong merged 1 commit into
apache:masterfrom
lintingbin:fix/resource-mapper-field-mapping
Apr 21, 2026
Merged

[Hotfix][ams] Fix ResourceMapper.selectResourcesByGroup result mapping#4194
zhoujinsong merged 1 commit into
apache:masterfrom
lintingbin:fix/resource-mapper-field-mapping

Conversation

@lintingbin
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix the @Result annotations on ResourceMapper.selectResourcesByGroup so that the property names actually match the fields on Resource:

Column Old property Correct property
group_name group groupName
container_name container containerName
total_memory totalMemory memoryMb

Also drop the start_time column from the SELECT list and remove its @Result entry. Resource has no startTime field, so the mapping was silently discarded — keeping the column in the projection added no value.

Why are the changes needed?

These mapping names have never matched the target class. Currently DefaultOptimizerManager.listResourcesByGroup is the only path that calls this mapper, and it has no caller on master, so the bug was latent. Any future caller (e.g. the auto-restart optimizer feature under development) that starts using this method would get back Resource instances with null/0 values in groupName, containerName, and memoryMb. Fixing it as a standalone change keeps the diff minimal and makes it safe to cherry-pick.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

  • Verified no current caller of selectResourcesByGroup / listResourcesByGroup exists on master besides the declaration itself, so the change cannot regress existing behavior.
  • mvn spotless:apply passes.

The @Result property names did not match the fields on Resource:
- group -> groupName
- container -> containerName
- totalMemory -> memoryMb

The start_time column and its @Result mapping were removed because
Resource has no startTime field; MyBatis would silently drop it anyway.

This method is currently only declared/implemented via
DefaultOptimizerManager.listResourcesByGroup with no caller on master,
so no behavioral change is observable. Fixing it now unblocks any future
caller (e.g. auto-restart feature) from getting back empty-field Resource
objects.
@github-actions github-actions Bot added the module:ams-server Ams server module label Apr 21, 2026
Copy link
Copy Markdown
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

The fix is correct and minimal.

All three @Result property names now match the actual fields on Resource (groupName, containerName, memoryMb), and the stale start_time mapping is correctly removed since Resource has no startTime field.

One minor note for future reference: the start_time column still exists in the DB schema (populated by DEFAULT CURRENT_TIMESTAMP) but has no corresponding field in Resource — this is intentional and the exclusion from result mapping is correct. Worth keeping in mind if the schema is ever revisited.

LGTM.

@zhoujinsong zhoujinsong merged commit dad2c9f into apache:master Apr 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ams-server Ams server module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants