avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: CronTimeTrigger bug
Date Wed, 01 Aug 2001 04:21:53 GMT
Hi,

I finally got a chance to look at this - soz for the delay ;)

On Mon, 30 Jul 2001 01:10, Bernhard Huber wrote:
> I was testing CronTimeTrigger and found a bug:
> Assume today is 29th July 2001
> You set a cron time trigger to 5th Feb 2002, then
> CronTimeTrigger will set next time running to
> 5th March 2002, not 5th Feb 2002

hmmm. I can't seem to reproduce this. Maybe I don't understand something ;)

I have added a method testRolledMonthDay() to
org.apache.avalon.cornerstone.services.scheduler.test.CronTimeTriggerTestlet

You can run the test via ./build.sh test

Does it function correctly at your end ? (could be something to do with 
localization if it doesn't).

Also have I understood problem correctly ? ;)

> In order to solve that problem, I check if the m_month has enough
> day,if not i set next to max days of m_month, like:

hmm. I am not sure I get you.  What you are saying is if we ask for day 29 in 
a 28 day month then we should set it to 28? Makes sense to me. 

However I can't see how it solves the above problem?

>         if( -1 != m_month ) {
>             // check if start: m_month, has enough days
>             Calendar cal_month = (GregorianCalendar)next.clone();
>             cal_month.set( Calendar.DAY_OF_MONTH, 1 );
>             cal_month.set( Calendar.MONTH, m_month );
>             int max_day_of_month = cal_month.getActualMaximum(
> Calendar.DAY_OF_MONTH );
>             if (max_day_of_month < next.get( Calendar.DAY_OF_MONTH )) {
>               next.set( Calendar.DAY_OF_MONTH, max_day_of_month );
>             }
>             // check if end
>             next.set( Calendar.MONTH, m_month );
>             if( -1 == m_hour ) next.set( Calendar.HOUR_OF_DAY, 0 );
>             if( -1 == m_minute ) next.set( Calendar.MINUTE, 0 );
>         }

I moved it down to after year is set so that you could also catch the case 
where you explicitly set the year. Other than that it works great - thanks!

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message