openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1838017 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/event/NotificationManager.java test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java
Date Tue, 14 Aug 2018 12:30:51 GMT
Author: rmannibucau
Date: Tue Aug 14 12:30:51 2018
New Revision: 1838017

URL: http://svn.apache.org/viewvc?rev=1838017&view=rev
Log:
OWB-1251 ensure fireAsync behaves properly when there is no observer

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1838017&r1=1838016&r2=1838017&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Tue Aug 14 12:30:51 2018
@@ -802,6 +802,10 @@ public final class NotificationManager
         {
             return null;
         }
+        if (completableFutures.isEmpty())
+        {
+            return CompletableFuture.completedFuture(event);
+        }
         CDICompletionFuture<T> future = new CDICompletionFuture<>(event, completableFutures.size());
         completableFutures.forEach(f -> f.handle((t, e) ->
         {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java?rev=1838017&r1=1838016&r2=1838017&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/async/ObserversAsyncTest.java
Tue Aug 14 12:30:51 2018
@@ -42,6 +42,8 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 public class ObserversAsyncTest extends AbstractUnitTest
 {
@@ -117,6 +119,27 @@ public class ObserversAsyncTest extends
         System.out.println("took ms: " + durationMs);
     }
 
+    @Test
+    public void testNoObserver() throws ExecutionException, InterruptedException
+    {
+        startContainer();
+        final CompletableFuture<ObserversAsyncTest> completionStage = getBeanManager()
+                .getEvent()
+                .fireAsync(new ObserversAsyncTest())
+                .handle((r, e) ->
+                {
+                    if (r != null)
+                    {
+                        return r;
+                    }
+                    fail();
+                    return null;
+                })
+                .toCompletableFuture();
+
+        assertTrue(completionStage.isDone());
+        assertTrue(ObserversAsyncTest.class.isInstance(completionStage.get()));
+    }
 
     public static class VisitorCollectorEvent
     {



Mime
View raw message