Skip to main content

RI not throwing TVTimerScheduleFailedException

12 replies [Last post]
ramks
Offline
Joined: 2010-06-17
Points: 0

I create a TVTimerSpec. I call setTime with -1, setDelayTime with -1 and setAbsoluteTime with -1. When I try to schedule this spec, I am not getting TVTimerScheduleFailedException.

In TimerMgrJava2.java, the argument of scheduleTimerSpec is not at all checked for sanity.

Isn't that a bug?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
scottdeboy
Offline
Joined: 2009-02-02
Points: 0

There is a bug here - the JavaDoc for the methods you reference requires an IllegalArgumentException to be thrown when the time argument is negative.

Please post an IssueTracker issue and I will take care of it.

Thanks
Scott

ramks
Offline
Joined: 2010-06-17
Points: 0

Why is it IllegalArgumentException? In the javadoc of TVTimer.scheduleTimerSpec(TVTimerSpec), all I see is "Throws:
TVTimerScheduleFailedException - is thrown when the scheduled specification cannot be satisfied." There is no mention of IllegalArgumentException.
Shouldn't the TVTimerScheduleFailedException be thrown as a past time request can never be satisfied?

scottdeboy
Offline
Joined: 2009-02-02
Points: 0

The setTime, setDelayTime and setAbsoluteTime method JavaDoc all document that an IllegalArgumentException is to be thrown if the time parameter is negative.

After I change the set*Time methods to throw IllegalArgumentException, it will be impossible to set a negative time on a TVTimerSpec.

tkooger
Offline
Joined: 2010-09-08
Points: 0

So how would you ever get the TVTimerScheduleFailedException from TVTimer?

scottdeboy
Offline
Joined: 2009-02-02
Points: 0

The JavaDoc for TVTimerspec.scheduleTimerSpec(TVTimerSpec) says:
"TVTimerScheduleFailedException is thrown when the scheduled specification cannot be satisfied."

Currently the code only throws a TVTimerScheduleFailedException if you pass in a null TVTimerSpec.

The logic tries to recover if there were problems scheduling the TVTimerSpec due to issues with the backing timer. This recovery logic is in a try/catch block that logs if an exception is thrown, and should throw the TVTimerScheduleFailedException in that case as well.

I will create a Jira issue to address this issue.

ramks
Offline
Joined: 2010-06-17
Points: 0

"Currently the code only throws a TVTimerScheduleFailedException if you pass in a null TVTimerSpec." - This is not true. The exception is thrown only when we use the TVTimer created by an app that was destroyed.

So that still leaves the question - how would you get the TVTimerScheduleFailedException from TVTimer?

scottdeboy
Offline
Joined: 2009-02-02
Points: 0

You are correct - a null timer spec passed into scheduleTimerSpec won't cause a TVTimerScheduleFailedException - only calling scheduleTimerSpec after the timer has been disposed will cause the exception.

As mentioned in a previous comment, the JavaDoc describes when the TVTimerScheduleFailedException should be thrown, and the implementation is catching all Exceptions and logging the exception, but should be throwing this exception in that Exception handler.

Once that change is made, all exceptions thrown will by the scheduleTimerSpec implementation will result in a TVTimerScheduleFailedException.

tgwozdz
Offline
Joined: 2009-06-23
Points: 0

Is there an Issue Tracker defect tracking this? Or has it been fixed already?

scottdeboy
Offline
Joined: 2009-02-02
Points: 0

Yes - it has been fixed and was tracked in IT-278.

srinivasrk
Offline
Joined: 2011-10-31
Points: 0

IT-278 is about fixing the issue "TVTimerSpec does not throw IllegalArgumentException for negative value". This fix ensures that TVTimerSpec throws IllegalArgumentException when we pass negative value.

So still the question remains - "How can we get TVTimerScheduleFailedException?".

srinivasrk
Offline
Joined: 2011-10-31
Points: 0

Any update on this?

srinivasrk
Offline
Joined: 2011-10-31
Points: 0

Hi All,

Any update on this?