Skip to content

fix: start the parent commit Optional empty instead of null - #292

Open
HuiJun wants to merge 1 commit into
developfrom
fix/branch-service-optional-null
Open

HuiJun wants to merge 1 commit into
developfrom
fix/branch-service-optional-null

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

DefaultBranchService.createBranch declared Optional<CommitJson> parentCommit = null and later tested parentCommit == null || !parentCommit.isPresent(). It now starts as Optional.empty() and the test is parentCommit.isEmpty().

Fixes SonarCloud issues AaHWUyQB45Pg1SGp66kH and AaHWUyQB45Pg1SGp66kI (java:S2789, DefaultBranchService.java:94 and :115).

Why it is safe

  • Same control flow: the only state the old null stood for is "no parent commit id given", which Optional.empty() now represents, and the one place that checked for null treats it identically to empty. Between the two lines parentCommit is either untouched or assigned a present value (an absent one throws BadRequestException first).
  • ./gradlew :crud:test passes (19 tests, 0 failures). No existing unit test calls createBranch directly; the Postman branch-creation requests in CI cover it.

Quality Assurance opened this PR for Jason
Implemented in session Get SonarCloud analysis landing for exec-mms
Review with Devin · Open in Devin Desktop


Fixes Sonar java:S2789 in DefaultBranchService.createBranch.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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