Fix potential race condition

init() is currently called outside of synhronized block.
This is may lead to race condition as init() creates new bus consumer
(this.consumer) which is the copied and nulled in stop() synchronized
block. This may lead to race condition if:

Thread #1   	     	     	       Thread #2

this.alive = true;
					this.alive = false
					consumerCopy = this.consumer;

this.consumer = new Consumer();

					// false
					if(consumerCopy != null) {
					    consumerCopy.close();
					} else {
					    log.warn();
					}

As a result, new BusConsumers are being created but they are never
close().

Issue-ID: POLICY-1387
Change-Id: I2eadb12ef1c4b07b9e47dc6ebc096acc713299a0
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
1 file changed
tree: 529e487b16876746535d80c1a5392e55005ab8f0
  1. capabilities/
  2. common-logging/
  3. common-parameters/
  4. integrity-audit/
  5. integrity-monitor/
  6. policy-endpoints/
  7. project-configs/
  8. utils/
  9. utils-test/
  10. .gitattributes
  11. .gitignore
  12. .gitreview
  13. INFO.yaml
  14. LICENSE.txt
  15. pom.xml
  16. README.md
  17. version.properties
README.md

Copyright 2018 AT&T Intellectual Property. All rights reserved. This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE Full license text at https://creativecommons.org/licenses/by/4.0/legalcode

This source repository contains ONAP common code, which is shared by 'policy-drools-pdp' and 'policy-engine'. To build it:

  1. using Maven 3
  2. git clone http://gerrit.onap.org/r/oparent and copy oparent/settings.xml to ~/.m2
  3. mvn clean install