You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2018/04/14 18:41:32 UTC

[cxf] branch master updated: Refactoring SSE broadcast test cases to fix the race conditions (between broadcasting and closing the broadcaster)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 0033697  Refactoring SSE broadcast test cases to fix the race conditions (between broadcasting and closing the broadcaster)
0033697 is described below

commit 0033697582635b8f36b69648f3750fd40c435981
Author: reta <dr...@gmail.com>
AuthorDate: Sat Apr 14 14:41:16 2018 -0400

    Refactoring SSE broadcast test cases to fix the race conditions (between broadcasting and closing the broadcaster)
---
 .../java/org/apache/cxf/systest/jaxrs/sse/BookStore.java   | 14 +++++++-------
 .../java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java  | 14 +++++++-------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
index a0c3fd8..ec6b1c0 100644
--- a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
+++ b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
@@ -121,16 +121,16 @@ public class BookStore {
             }
 
             final Builder builder = sse.newEventBuilder();
-            broadcaster.broadcast(createStatsEvent(builder.name("book"), 1000));
-            broadcaster.broadcast(createStatsEvent(builder.name("book"), 2000));
-
+            broadcaster.broadcast(createStatsEvent(builder.name("book"), 1000))
+                .thenAcceptBoth(broadcaster.broadcast(createStatsEvent(builder.name("book"), 2000)), (a, b) -> { })
+                .whenComplete((r, ex) -> { 
+                    if (broadcaster != null) {
+                        broadcaster.close();
+                    }
+                });
         } catch (final InterruptedException ex) {
             LOG.error("Wait has been interrupted", ex);
         }
-
-        if (broadcaster != null) {
-            broadcaster.close();
-        }
     }
 
     private static OutboundSseEvent createStatsEvent(final OutboundSseEvent.Builder builder, final int eventId) {
diff --git a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
index f97906c..dc76876 100644
--- a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
+++ b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
@@ -120,16 +120,16 @@ public class BookStore2 {
             }
 
             final Builder builder = sse.newEventBuilder();
-            broadcaster.broadcast(createStatsEvent(builder.name("book"), 1000));
-            broadcaster.broadcast(createStatsEvent(builder.name("book"), 2000));
-
+            broadcaster.broadcast(createStatsEvent(builder.name("book"), 1000))
+                .thenAcceptBoth(broadcaster.broadcast(createStatsEvent(builder.name("book"), 2000)), (a, b) -> { })
+                .whenComplete((r, ex) -> { 
+                    if (broadcaster != null) {
+                        broadcaster.close();
+                    }
+                });
         } catch (final InterruptedException ex) {
             LOG.error("Wait has been interrupted", ex);
         }
-
-        if (broadcaster != null) {
-            broadcaster.close();
-        }
     }
 
     private static OutboundSseEvent createStatsEvent(final OutboundSseEvent.Builder builder, final int eventId) {

-- 
To stop receiving notification emails like this one, please contact
reta@apache.org.