* Fix bug 435, cron jobs are run even if the function name is not defined
* Fix a bug that caused the scheduler thread to awaken twice in immedate succession because of imprecise timing in Thread.sleep()
This commit is contained in:
parent
37e51812d6
commit
6d4978f652
1 changed files with 19 additions and 2 deletions
|
@ -193,6 +193,8 @@ public class CronJob {
|
||||||
StringTokenizer st = new StringTokenizer (key.trim(), ".");
|
StringTokenizer st = new StringTokenizer (key.trim(), ".");
|
||||||
st.nextElement ();
|
st.nextElement ();
|
||||||
String jobName = st.nextToken ();
|
String jobName = st.nextToken ();
|
||||||
|
if (jobName == null || jobName.equals(""))
|
||||||
|
continue;
|
||||||
String jobSpec = st.nextToken ();
|
String jobSpec = st.nextToken ();
|
||||||
if (jobSpec==null || jobSpec.equals("")) // might happen with cron.testname. = XXX
|
if (jobSpec==null || jobSpec.equals("")) // might happen with cron.testname. = XXX
|
||||||
continue;
|
continue;
|
||||||
|
@ -222,7 +224,16 @@ public class CronJob {
|
||||||
} catch (NoSuchElementException nsee) {
|
} catch (NoSuchElementException nsee) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List jobVec = new ArrayList (jobs.values ());
|
Iterator it = jobs.values().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
CronJob job = (CronJob) it.next();
|
||||||
|
if (job.getFunction() == null) {
|
||||||
|
System.err.println("DROPPING CRON JOB " + job);
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List jobVec = new ArrayList (jobs.values());
|
||||||
|
System.err.println("GOT CRON JOB LIST: " + jobVec);
|
||||||
return sort (jobVec);
|
return sort (jobVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +423,13 @@ public class CronJob {
|
||||||
public static long millisToNextFullMinute () {
|
public static long millisToNextFullMinute () {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long millisAfterMinute = (now % 60000);
|
long millisAfterMinute = (now % 60000);
|
||||||
return (60000 - millisAfterMinute);
|
// We return the interval to one second past the next full minute
|
||||||
|
// to avoid the case where the scheduler wakes up slightly before the minute
|
||||||
|
// and finishes so fast that the next call to this method returns the
|
||||||
|
// interval to the same minute instead of the next one. This happened
|
||||||
|
// sometimes with the old code and caused the scheduler to run twice in
|
||||||
|
// immediate succession.
|
||||||
|
return (61000 - millisAfterMinute);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue