8000 Once a month schedule not working due to int overflow in AutomaticUpdateScheduler.computeFuzzyPoll() · Issue #862 · eclipse-equinox/p2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Once a month schedule not working due to int overflow in AutomaticUpdateScheduler.computeFuzzyPoll() #862
Open
@swtdev

Description

@swtdev

We have a catch-all exception handler in our RCP and have had a few reports of an IllegalArgumentException on setting the auto-update check schedule, e.g.

java.lang.IllegalArgumentException
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.scheduleAtFixedRate(Unknown Source)
	at java.base/java.util.concurrent.Executors$DelegatedScheduledExecutorService.scheduleAtFixedRate(Unknown Source)
	at a.b.v.b.d.addUpdateCheck(d.java:34)
	at org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler.scheduleUpdate(AutomaticUpdateScheduler.java:156)
	at org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler.rescheduleUpdate(AutomaticUpdateScheduler.java:121)
	at a.b.v.c.c.performOk(c.java:101)
	at org.eclipse.jface.preference.PreferencePage.performApply(PreferencePage.java:454)

It's caused by being passed values <= 0. I've finally spotted what the issue is, it's in the calculation for the monthly schedule here:

	private static final int ONE_HOUR_IN_MS = 60 * 60 * 1000;
	private static final int ONE_DAY_IN_MS = 24 * ONE_HOUR_IN_MS;

The method is returning a long but the calc is done with ints where

30 * 24 * 60 * 60 * 1000 = 2,592,000,000

which is actually bigger than the int max value of 2,147,483,647 so overflow occurs and a negative result it actually returned.

Perhaps the constants should be changed to longs or the calc changed to use 30L...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0