Return true only if thread has been really started 04/77604/5
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 30 Jan 2019 18:55:20 +0000 (19:55 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 8 Feb 2019 15:05:52 +0000 (16:05 +0100)
Accortding to doc start() should return true if start operation was
successful. Unfortunately value of this.alive may change between end
of synchronized block and return for example when other thread
executes stop() in parallel.

Change-Id: I4103f0f4c65620c47b4acf2d276f104937b91187
Issue-ID: POLICY-1387
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java

index 4cc8fbb..83f3760 100644 (file)
@@ -172,6 +172,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
                     this.busPollerThread = makePollerThread();
                     this.busPollerThread.setName(this.getTopicCommInfrastructure() + "-source-" + this.getTopic());
                     busPollerThread.start();
+                    return true;
                 } catch (Exception e) {
                     logger.warn("{}: cannot start because of {}", this, e.getMessage(), e);
                     throw new IllegalStateException(e);
@@ -179,7 +180,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
             }
         }
 
-        return this.alive;
+        return false;
     }
 
     /**