[jboss-cvs] JBossAS SVN: r64392 - branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/ejb/txtimer.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 31 21:50:15 EDT 2007
Author: jhowell at redhat.com
Date: 2007-07-31 21:50:15 -0400 (Tue, 31 Jul 2007)
New Revision: 64392
Modified:
branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
Log:
[ASPATCH-249] The TimerImpl patch ported from the one off patch in 4.0.2
Modified: branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-07-31 21:03:03 UTC (rev 64391)
+++ branches/JBoss_4_0_3_SP1_CP/server/src/main/org/jboss/ejb/txtimer/TimerImpl.java 2007-08-01 01:50:15 UTC (rev 64392)
@@ -105,6 +105,7 @@
TimerServiceImpl timerService = getTimerService();
timerService.addTimer(this);
registerTimerWithTx();
+ // the timer will actually go ACTIVE on tx commit
startInTx();
}
@@ -143,6 +144,11 @@
return !isCanceled() && !isExpired();
}
+ public boolean isInRetry()
+ {
+ return timerState == RETRY_TIMEOUT;
+ }
+
public boolean isCanceled()
{
return timerState == CANCELED_IN_TX || timerState == CANCELED;
@@ -324,19 +330,29 @@
private void startInTx()
{
TimerServiceImpl timerService = getTimerService();
-
utilTimer = new Timer();
- if (periode > 0)
- utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire), periode);
- else
- utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire));
-
+
if (timerService.getTransaction() != null)
+ {
+ // don't schedule the timeout yet
setTimerState(STARTED_IN_TX);
+ }
else
+ {
+ scheduleTimeout();
setTimerState(ACTIVE);
+ }
}
+ private void scheduleTimeout()
+ {
+ TimerServiceImpl timerService = getTimerService();
+ if (periode > 0)
+ utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire), periode);
+ else
+ utilTimer.schedule(new TimerTaskImpl(this), new Date(nextExpire));
+ }
+
private void cancelInTx()
{
TimerServiceImpl timerService = getTimerService();
@@ -413,9 +429,12 @@
log.debug("commit: " + this);
if (timerState == STARTED_IN_TX)
+ {
+ scheduleTimeout();
setTimerState(ACTIVE);
+ }
else if (timerState == CANCELED_IN_TX)
- setTimerState(CANCELED);
+ killTimer();
else if (timerState == IN_TIMEOUT || timerState == RETRY_TIMEOUT)
setTimerState(periode == 0 ? EXPIRED : ACTIVE);
}
@@ -437,7 +456,7 @@
Object instancePk = timedObjectId.getInstancePk();
ejbTimerService.retryTimeout(containerId, instancePk, this);
}
- else if (timerState == IN_TIMEOUT || timerState == RETRY_TIMEOUT)
+ else if (timerState == RETRY_TIMEOUT)
setTimerState(periode == 0 ? EXPIRED : ACTIVE);
}
}
@@ -461,10 +480,16 @@
public void run()
{
log.debug("run: " + timer);
-
if (isActive() && periode > 0)
nextExpire += periode;
+ // If a retry thread is in progress, we don't want to allow another
+ // interval to execute until the retry is complete. See JIRA-1926.
+ if (isInRetry())
+ {
+ log.debug("Timer in retry mode, skipping this scheduled execution");
+ return;
+ }
if (isActive())
{
try
More information about the jboss-cvs-commits
mailing list