Skip to content

CURATOR-262. Fix sleepMs overflow - #490

Merged
tisonkun merged 1 commit into
apache:masterfrom
shenjianeng:fix-overflow
Dec 20, 2023
Merged

CURATOR-262. Fix sleepMs overflow#490
tisonkun merged 1 commit into
apache:masterfrom
shenjianeng:fix-overflow

Conversation

@shenjianeng

Copy link
Copy Markdown
Contributor

fix sleepMs overflow

public class Main {
    private static final Random random = new Random();
    private static int baseSleepTimeMs = Integer.MAX_VALUE;

    public static void main(String[] args) {
        int retryCount = 2;
        long sleepMs1 = baseSleepTimeMs * Math.min(2, random.nextInt(1 << (retryCount + 1)));
        long sleepMs2 = (long) baseSleepTimeMs * Math.min(2, random.nextInt(1 << (retryCount + 1)));
        System.out.println(sleepMs1);
        System.out.println(sleepMs2);
    }
}

@tisonkun tisonkun 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.

Thank you!

@tisonkun tisonkun changed the title fix sleepMs overflow Dec 8, 2023
@tisonkun

tisonkun commented Dec 8, 2023

Copy link
Copy Markdown
Member

This is actually a follow-up to #136 where we introduce the bug by missing integers casting.

@tisonkun

Copy link
Copy Markdown
Member

Merging ...

Thanks for your contribution!

@tisonkun
tisonkun merged commit 111f3a6 into apache:master Dec 20, 2023
@shenjianeng
shenjianeng deleted the fix-overflow branch December 20, 2023 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants