Skip to content

Fix LogDTO.compareTo to avoid overflow and contract violation#5304

Merged
holgerfriedrich merged 1 commit into
openhab:mainfrom
jlaur:logdto-compareto
Jan 25, 2026
Merged

Fix LogDTO.compareTo to avoid overflow and contract violation#5304
holgerfriedrich merged 1 commit into
openhab:mainfrom
jlaur:logdto-compareto

Conversation

@jlaur

@jlaur jlaur commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur jlaur requested a review from a team as a code owner January 24, 2026 22:38
@holgerfriedrich holgerfriedrich added the bug An unexpected problem or unintended behavior of the Core label Jan 25, 2026

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 pull request fixes a critical bug in LogDTO.compareTo where casting the result of long subtraction to int could cause integer overflow and violate the Comparable contract.

Changes:

  • Replaced (int) (sequence - o.sequence) with Long.compare(sequence, o.sequence) to prevent overflow

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

@holgerfriedrich holgerfriedrich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@holgerfriedrich holgerfriedrich merged commit 9a4193a into openhab:main Jan 25, 2026
12 checks passed
@holgerfriedrich holgerfriedrich added this to the 5.2 milestone Jan 25, 2026
@jlaur jlaur deleted the logdto-compareto branch January 25, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An unexpected problem or unintended behavior of the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants