Add default values for health-api properties 29/99129/2
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 4 Dec 2019 09:59:15 +0000 (11:59 +0200)
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 4 Dec 2019 10:29:37 +0000 (12:29 +0200)
Issue-ID: CCSDK-1669

Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: I28d6c829a8f6d41aee52a21b9391b7f642359756

ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt

index 8d4a27f..8fcffbf 100644 (file)
 
 package org.onap.ccsdk.cds.blueprintsprocessor.actuator.indicator
 
+import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
 import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.BluePrintProcessorHealthCheck
+import org.slf4j.LoggerFactory
 import org.springframework.boot.actuate.health.AbstractHealthIndicator
 import org.springframework.boot.actuate.health.Health
 import org.springframework.stereotype.Component
@@ -30,16 +32,25 @@ import org.springframework.stereotype.Component
  */
 @Component
 open class BluePrintCustomIndicator(private val bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck) :
-    AbstractHealthIndicator() {
+        AbstractHealthIndicator() {
+
+    private var logger = LoggerFactory.getLogger(BluePrintCustomIndicator::class.java)
 
     @Throws(Exception::class)
     override fun doHealthCheck(builder: Health.Builder) {
-        var result: HealthApiResponse? = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
-        if (result?.status == HealthCheckStatus.UP) {
-            builder.up()
-        } else {
-            builder.down()
+        runBlocking {
+            var result: HealthApiResponse? = null
+            try {
+                result = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+                if (result?.status == HealthCheckStatus.UP) {
+                    builder.up()
+                } else {
+                    builder.down()
+                }
+                builder.withDetail("Services", result?.checks)
+            } catch (exception: IllegalArgumentException) {
+                logger.error(exception.message)
+            }
         }
-        builder.withDetail("Services", result?.checks)
     }
 }
index 080a26e..f64cba8 100644 (file)
@@ -26,16 +26,16 @@ import org.springframework.context.annotation.PropertySource
 @PropertySource("classpath:application.properties")
 open class HealthCheckProperties {
 
-    @Value("\${blueprintprocessor.healthcheck.baseUrl}")
+    @Value("\${blueprintprocessor.healthcheck.baseUrl:}")
     private val bluePrintProcessorBaseURL: String? = null
 
-    @Value("#{'\${blueprintprocessor.healthcheck.mapping-service-name-with-service-link}'.split(']')}")
+    @Value("#{'\${blueprintprocessor.healthcheck.mapping-service-name-with-service-link:}'.split(']')}")
     private val blueprintprocessorServiceMapping: List<String>? = null
 
-    @Value("\${cdslistener.healthcheck.baseUrl}")
+    @Value("\${cdslistener.healthcheck.baseUrl:}")
     private val cdsListenerBaseURL: String? = null
 
-    @Value("#{'\${cdslistener.healthcheck.mapping-service-name-with-service-link}'.split(']')}")
+    @Value("#{'\${cdslistener.healthcheck.mapping-service-name-with-service-link:}'.split(']')}")
     private val cdsListenerServiceMapping: List<String>? = null
 
     open fun getBluePrintBaseURL(): String? {