Formatting Code base with ktlint
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / rest-lib / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / rest / service / RestLoggerService.kt
index 969de83..dbb98f8 100644 (file)
 
 package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
 
-import kotlinx.coroutines.*
+import kotlinx.coroutines.AbstractCoroutine
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.InternalCoroutinesApi
+import kotlinx.coroutines.handleCoroutineException
+import kotlinx.coroutines.newCoroutineContext
 import kotlinx.coroutines.reactor.ReactorContext
 import kotlinx.coroutines.reactor.asCoroutineContext
 import org.apache.http.message.BasicHeader
@@ -37,7 +43,7 @@ import java.net.InetAddress
 import java.time.ZoneOffset
 import java.time.ZonedDateTime
 import java.time.format.DateTimeFormatter
-import java.util.*
+import java.util.UUID
 import kotlin.coroutines.CoroutineContext
 import kotlin.coroutines.EmptyCoroutineContext
 
@@ -89,17 +95,19 @@ class RestLoggerService {
     }
 }
 
-
 /** Used in Rest controller API methods to populate MDC context to nested coroutines from reactor web filter context. */
 @UseExperimental(InternalCoroutinesApi::class)
-fun <T> monoMdc(context: CoroutineContext = EmptyCoroutineContext,
-                block: suspend CoroutineScope.() -> T?): Mono<T> = Mono.create { sink ->
+fun <T> monoMdc(
+    context: CoroutineContext = EmptyCoroutineContext,
+    block: suspend CoroutineScope.() -> T?
+): Mono<T> = Mono.create { sink ->
 
     val reactorContext = (context[ReactorContext]?.context?.putAll(sink.currentContext())
-            ?: sink.currentContext()).asCoroutineContext()
+        ?: sink.currentContext()).asCoroutineContext()
     /** Populate MDC context only if present in Reactor Context */
-    val newContext = if (!reactorContext.context.isEmpty
-            && reactorContext.context.hasKey(MDCContext)) {
+    val newContext = if (!reactorContext.context.isEmpty &&
+        reactorContext.context.hasKey(MDCContext)
+    ) {
         val mdcContext = reactorContext.context.get<MDCContext>(MDCContext)
         GlobalScope.newCoroutineContext(context + reactorContext + mdcContext)
     } else GlobalScope.newCoroutineContext(context + reactorContext)
@@ -111,9 +119,10 @@ fun <T> monoMdc(context: CoroutineContext = EmptyCoroutineContext,
 
 @InternalCoroutinesApi
 class MonoMDCCoroutine<in T>(
-        parentContext: CoroutineContext,
-        private val sink: MonoSink<T>
+    parentContext: CoroutineContext,
+    private val sink: MonoSink<T>
 ) : AbstractCoroutine<T>(parentContext, true), Disposable {
+
     private var disposed = false
 
     override fun onCompleted(value: T) {