[Opensource] Multiple job bug
Marcus Lindberg
lindbergmarcus at hotmail.com
Thu Oct 3 07:16:53 PDT 2002
I had a problem with jobs disapearing. It was tracked down to the
notifyListeners() method in the Crontab class of the
com.jcorporate.expresso.services.crontab package:
// Reactivates the alarm if it is repetitive
if (entry.isRepetitive) {
entry.updateEntryTime();
queue.add(entry);
}
The CrontabEntry objects in the queue are compared with alarmTime. If there
already is a CrontabEntry in the queue with the same alarmtime as the entry
being added then its not added into the queue.
This was solved by changing the compareTo and equals methods in the
CrontabEntry class to:
public int compareTo(Object obj) {
CrontabEntry entry = (CrontabEntry)obj;
if (alarmTime < entry.alarmTime)
return -1;
if (alarmTime > entry.alarmTime)
return 1;
if(listener == entry.listener)
return 0;
return 1;
}
public boolean equals(Object obj) {
CrontabEntry entry = (CrontabEntry)obj;
if (alarmTime == entry.alarmTime && listener == entry.listener) {
return true;
}
return false;
}
An CrontabEntry is only considered equal if having the same alarmtime and
listener.
It works with my jobs. Anyone who can see any bad of effects of this change?
I am considering making a simple change to allow jobs to be run every x
minutes using cronparams of -x. It should be pretty fast to implement. Is
there any interest of this feature?
/Marcus Lindberg
_________________________________________________________________
MSN Hotmail är världens populäraste e-posttjänst. Skaffa dig ett eget konto
du också: http://www.hotmail.com
More information about the Opensource
mailing list