Skip to content

fix(strictKex): null check in isStrictKex#504

Merged
kruton merged 1 commit into
connectbot:mainfrom
kruton:strict-kex-null-check
Jun 9, 2026
Merged

fix(strictKex): null check in isStrictKex#504
kruton merged 1 commit into
connectbot:mainfrom
kruton:strict-kex-null-check

Conversation

@kruton

@kruton kruton commented Jun 9, 2026

Copy link
Copy Markdown
Member

If one calls the isStrictKex before negotiation has completed, the negotiated parameters would be null and result in a NullPointerException. Change the semantics of the call slightly to mean "has strict KEX been negotiated."

If one calls the isStrictKex before negotiation has completed, the
negotiated parameters would be null and result in a NullPointerException.
Change the semantics of the call slightly to mean "has strict KEX been
negotiated."
Copilot AI review requested due to automatic review settings June 9, 2026 16:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts KexManager.isStrictKex() semantics to mean “has strict KEX been negotiated (yet)?” and adds a regression test to prevent a NullPointerException when the method is called before KEX negotiation completes.

Changes:

  • Add a null-safe check in KexManager.isStrictKex() to avoid NPEs before negotiated parameters are available.
  • Add a JUnit test covering isStrictKex() behavior prior to negotiation completion.

Reviewed changes

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

File Description
src/main/java/com/trilead/ssh2/transport/KexManager.java Makes isStrictKex() safe to call when KEX negotiation has not completed.
src/test/java/com/trilead/ssh2/transport/KexManagerTest.java Adds regression coverage for calling isStrictKex() before negotiation completion.

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

Comment thread src/main/java/com/trilead/ssh2/transport/KexManager.java
@kruton kruton force-pushed the strict-kex-null-check branch from ec51aae to ffd456e Compare June 9, 2026 18:17
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@kruton kruton merged commit 358282f into connectbot:main Jun 9, 2026
6 checks passed
@kruton kruton deleted the strict-kex-null-check branch June 9, 2026 18:22
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