Re: WOApplication's TimeoutTask inner class question
Re: WOApplication's TimeoutTask inner class question
- Subject: Re: WOApplication's TimeoutTask inner class question
- From: Chuck Hill <email@hidden>
- Date: Thu, 30 Apr 2009 11:44:12 -0700
My guess is that is it just wrong, never tested, and not used by anyone.
Chuck
On Apr 30, 2009, at 8:49 AM, Bogdan Zlatanov wrote:
Hello everybody,
I've been JAD-ing around WOSession and WOApplication out of
curiousity and bumped into this inner for WOApplication class:
protected class TimeoutTask extends TimerTask {
protected TimeoutTask() {
super();
}
public void start() {
applicationTimer().schedule(this, (long)(timeOut() *
1000D));
}
public void run() {
long inactivity = System.currentTimeMillis() -
WOApplication._TheLastApplicationAccessTime;
if((double)inactivity >= timeOut())
terminate();
else
applicationTimer().schedule(this, (long)(timeOut() *
1000D) - inactivity); (*)
}
public boolean cancel() {
return super.cancel();
}
}
Looking at the (*) bolded line in the else block I couldn't help
spotting that an attempt to reuse both the timer, which is usually
OK, and the TimerTask? Now, this shouldn't be possible according to
the JDK docs, so I've tried it and of course got the expected
"Exception in thread "Timer-0" java.lang.IllegalStateException:
Task already scheduled or cancelled"
error.
Another thing is the checked condition in the if statement -
comparing milliseconds to seconds, since inactivity holds the
milliseconds since last application access time, and timeOut()
returns the time out in seconds, which is kind of explaining why the
else block is usually skipped.
It might be a very stupid and obvious thing, but I'd appreciate
if anyone can explain to me why (*) would work for WO and not for me?
Cheers,
Bogdan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Chuck Hill Senior Consultant / VP Development
Come to WOWODC'09 in San Fran this June!
http://www.wocommunity.org/wowodc09/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden