Issue Details (XML | Word | Printable)

Key: QRTZNET-73
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Marko Lahma
Reporter: Marko Lahma
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Quartz.NET

ComputeFirstFireTimeUtc fails when GetFireTimeAfter returns null

Created: 03/Dec/07 09:06 AM   Updated: 20/Jan/08 11:22 AM
Component/s: Triggers
Affects Version/s: None
Fix Version/s: 0.9.1


 Description  « Hide
From maliling list:

When tracking down a bug in my code caused by the DailyCalendar
expecting Utc dates, I encountered a bug In SimpleTrigger's
ComputeFirstFireTimeUtc method using .NET Framework 2.0.
GetFireTimeAfter can return a null value, causing the "return
nextFireTimeUtc.Value" statement to throw an exception. I fixed this
by removing ".Value", and all tests pass so I guess this is a viable
fix?

Here's a test case which illustrates the problem. You probably want to
clean it up and change its name if you want to add it to your source -
I simply copied and adjusted the TestGetFireTimeAfter method:

[Test]
[ExpectedException(ExceptionType = typeof(SchedulerException))]
public void TestGetFireTimeAfterWithCalendar()
{
   ISchedulerFactory sf = new Quartz.Impl.StdSchedulerFactory();
   IScheduler sched = sf.GetScheduler();

   DailyCalendar dailyCalendar = new DailyCalendar("1:20", "14:50");

   SimpleTrigger simpleTrigger = new SimpleTrigger();

   DateTime neverFireTime =
TriggerUtils.GetEvenMinuteDateBefore(dailyCalendar.GetTimeRangeStartingTime(DateTime.Now));

   simpleTrigger.StartTimeUtc = neverFireTime;
   simpleTrigger.RepeatInterval = 10;
   simpleTrigger.RepeatCount = 4;
   simpleTrigger.CalendarName = "test";
   simpleTrigger.Name = "simpleTrigger";

   sched.AddCalendar("test", dailyCalendar, true, true);
   JobDetail job = new JobDetail("job1", "test",
typeof(SimpleTriggerTestJob));
   sched.ScheduleJob(job, simpleTrigger);

   NullableDateTime fireTimeAfter = sched.GetTriggersOfJob("job1",
"test")[0].GetNextFireTimeUtc();

   Assert.IsNull(fireTimeAfter);
}

public class SimpleTriggerTestJob : IJob
{
   public void Execute(JobExecutionContext context)
   {
       throw new NotImplementedException();
   }
}

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.