tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-2065 @Stateful can fail timerservice.getAllTimers()
Date Thu, 15 Jun 2017 07:20:15 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 7708df488 -> 3684660ea


TOMEE-2065 @Stateful can fail timerservice.getAllTimers()


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3684660e
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3684660e
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3684660e

Branch: refs/heads/master
Commit: 3684660ea75a8d211e3b27009fb10e94b4b89479
Parents: 7708df4
Author: rmannibucau <rmannibucau@apache.org>
Authored: Thu Jun 15 09:20:09 2017 +0200
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Thu Jun 15 09:20:09 2017 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/openejb/core/timer/Timers.java   |  3 +++
 .../org/apache/openejb/core/timer/GetAllTimersTest.java   | 10 ++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3684660e/container/openejb-core/src/main/java/org/apache/openejb/core/timer/Timers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/Timers.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/Timers.java
index 273d109..a5f51cd 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/timer/Timers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/timer/Timers.java
@@ -71,6 +71,9 @@ public final class Timers {
     public static TimerService getTimerService(final Object pk, final BeanContext beanContext,
final boolean nullIfNotRelevant) throws IllegalStateException {
         final EjbTimerService timerService = beanContext.getEjbTimerService();
         if (timerService == null) {
+            if (nullIfNotRelevant) {
+                return null;
+            }
             throw new IllegalStateException("This ejb does not support timers " + beanContext.getDeploymentID());
         } else if (beanContext.getEjbTimeout() == null) {
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/3684660e/container/openejb-core/src/test/java/org/apache/openejb/core/timer/GetAllTimersTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/timer/GetAllTimersTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/core/timer/GetAllTimersTest.java
index 985d09c..ae92370 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/timer/GetAllTimersTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/timer/GetAllTimersTest.java
@@ -18,6 +18,7 @@ package org.apache.openejb.core.timer;
 
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.StatefulBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.testing.Module;
 import org.junit.Test;
@@ -28,6 +29,7 @@ import javax.annotation.Resource;
 import javax.ejb.EJB;
 import javax.ejb.Singleton;
 import javax.ejb.Startup;
+import javax.ejb.Stateful;
 import javax.ejb.Timeout;
 import javax.ejb.Timer;
 import javax.ejb.TimerConfig;
@@ -50,6 +52,7 @@ public class GetAllTimersTest {
     @Module
     public EjbJar jar() {
         return new EjbJar()
+            .enterpriseBean(new StatefulBean(NoTimer.class).localBean())
             .enterpriseBean(new SingletonBean(Query.class).localBean())
             .enterpriseBean(new SingletonBean(Bean1.class).localBean())
             .enterpriseBean(new SingletonBean(Bean2.class).localBean());
@@ -86,6 +89,13 @@ public class GetAllTimersTest {
         assertEquals(Bean2.class.getSimpleName(), it.next().getInfo());
     }
 
+    @Stateful
+    public static class NoTimer {
+        public void justHereToEnsureWeDontFailIfABeanHasNoTimer() {
+            // no-op
+        }
+    }
+
     @Startup
     public static class TimerBean {
         @Resource


Mime
View raw message