Skip to content

Comments

Fix NPE when spending XP on new skills #8715

Merged
HammerGS merged 1 commit intomainfrom
Fix-8707-Skill-XP-NPE
Feb 2, 2026
Merged

Fix NPE when spending XP on new skills #8715
HammerGS merged 1 commit intomainfrom
Fix-8707-Skill-XP-NPE

Conversation

@HammerGS
Copy link
Member

@HammerGS HammerGS commented Feb 2, 2026

Root Cause

When spending XP to acquire a new skill, getSkill() returns null before the skill exists. After improveSkill() creates
the skill, the local skill variable was never updated, causing a NullPointerException when accessing skill.getType()
and skill.getLevel().

Changes

  1. PersonnelTableMouseAdapter.java - Re-fetch the skill after improveSkill() creates it

Files Changed

  • MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java - Added skill re-fetch after creation

Fixes #8707

Root Cause

  When spending XP to acquire a new skill, getSkill() returns null before the skill exists. After improveSkill() creates
   the skill, the local skill variable was never updated, causing a NullPointerException when accessing skill.getType()
  and skill.getLevel().

  Changes

  1. PersonnelTableMouseAdapter.java - Re-fetch the skill after improveSkill() creates it

  Files Changed

  - MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java - Added skill re-fetch after creation
Copilot AI review requested due to automatic review settings February 2, 2026 01:01
@HammerGS HammerGS requested a review from a team as a code owner February 2, 2026 01:01
@HammerGS HammerGS added AI Generated Code AI-generated fix. Requires human testing and review before merging. Needs Player Testing PR lacks actual play testing. labels Feb 2, 2026
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

Fixes a NullPointerException when spending XP to acquire a brand-new skill by ensuring the newly created skill is re-fetched before it’s used for logging/reporting.

Changes:

  • After improveSkill() potentially creates a missing skill, re-fetch the Skill instance from the Person before accessing its type/level.

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

Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

LGTM

@HammerGS HammerGS merged commit c488c5f into main Feb 2, 2026
12 checks passed
@HammerGS HammerGS deleted the Fix-8707-Skill-XP-NPE branch February 2, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Code AI-generated fix. Requires human testing and review before merging. Needs Player Testing PR lacks actual play testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue] Spending XP to Add Negotiation Skill Triggers NPE

2 participants