Skip to content

Ensure version starts with 'v' in VersionChecker#704

Open
acornejo wants to merge 1 commit into
freerouting:masterfrom
acornejo:acornejo-patch-1
Open

Ensure version starts with 'v' in VersionChecker#704
acornejo wants to merge 1 commit into
freerouting:masterfrom
acornejo:acornejo-patch-1

Conversation

@acornejo
Copy link
Copy Markdown

@acornejo acornejo commented Jun 5, 2026

This fixes a bug with version checker, since currently it fed strings of the form '1.2.3' and compares them against strings of the form 'v1.2.3' which always results in a mismatch.

Description

Please explain the changes you made here.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

This fixes a bug with version checker, since currently it fed strings of the form '1.2.3' and compares them against strings of the form 'v1.2.3' which always results in a mismatch.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the VersionChecker constructor to ensure the version string is prefixed with 'v' if it is not already. Feedback on these changes highlights a potential NullPointerException if the version parameter is null, and points out that modifying the static field CURRENT_VERSION within an instance constructor is a code smell that could lead to race conditions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +20 to +24
if (version.startsWith("v")) {
CURRENT_VERSION = version;
} else {
CURRENT_VERSION = "v" + version;
}
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.

medium

There are two issues here:

  1. Potential NullPointerException: If the version parameter is null, calling version.startsWith("v") will throw a NullPointerException.
  2. Static Field Modification: Modifying the static field CURRENT_VERSION from an instance constructor is a code smell and can lead to race conditions if multiple instances of VersionChecker are created. Ideally, CURRENT_VERSION should be an instance field (non-static), but at a minimum, we should guard against null values here.
    if (version == null) {
      CURRENT_VERSION = "v1.0";
    } else if (version.startsWith("v")) {
      CURRENT_VERSION = version;
    } else {
      CURRENT_VERSION = "v" + version;
    }

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