Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The overflow of integers causes the failure of alarm convergence #1527

Closed
1 task done
MushroomBear opened this issue Feb 2, 2024 · 3 comments
Closed
1 task done
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@MushroomBear
Copy link

MushroomBear commented Feb 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

org.dromara.hertzbeat.alert.reduce.AlarmConvergeReduce#filterConverge

if (match) {
    long evalInterval = alertConverge.getEvalInterval() * 1000;
    long now = System.currentTimeMillis();
    if (evalInterval <= 0) {
        return true;
    }
    ......
}

The type of integer multiplied by integer is integer. When alertConverge.getEvalInterval() is set to the maximum value of integer, overflow will occur after multiplying by 1000, and the result will be 0, which leads to the condition if (evalInterval <= 0) becoming true, and cannot perform alarm convergence.

Expected Behavior

if (match) {
    long evalInterval = alertConverge.getEvalInterval() * 1000L;
    long now = System.currentTimeMillis();
    if (evalInterval <= 0) {
        return true;
    }
    ......
}

The type of alertConverge.getEvalInterval() * 1000L is long,will not overflow.

Steps To Reproduce

None

Environment

v1.4.4

Debug logs

None

Anything else?

None

@MushroomBear MushroomBear added the bug Something isn't working label Feb 2, 2024
@tomsun28 tomsun28 added the good first issue Good for newcomers label Feb 2, 2024
@tomsun28 tomsun28 added this to the 1.4.5 milestone Feb 2, 2024
@tomsun28
Copy link
Contributor

tomsun28 commented Feb 2, 2024

hi, 👍👍. has confirmed this. Can you help us to fix it?
I think we can limit the max evalInterval or fix the overflow of the integer

@tomsun28 tomsun28 modified the milestones: 1.5.0, 1.5.1 Feb 15, 2024
@Calvin979
Copy link
Contributor

I‘d like to help!

@tomsun28
Copy link
Contributor

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants