diff options
-rw-r--r-- | hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt index b0f877f0..9cade1cc 100644 --- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt +++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/VesHvCollector.kt @@ -59,13 +59,7 @@ internal class VesHvCollector( return valid } - private fun findRoute(msg: VesMessage): Mono<RoutedMessage> { - val routedMessage = router.findDestination(msg) - return if (routedMessage == null) - Mono.empty() - else - Mono.just(routedMessage) - } + private fun findRoute(msg: VesMessage): Mono<RoutedMessage> = omitWhenNull(msg, router::findDestination) private fun releaseMemory(msg: VesMessage) { msg.rawMessage.release() @@ -73,8 +67,7 @@ internal class VesHvCollector( - private fun <T>omitWhenNull(input: ByteBuf, mapper: (ByteBuf) -> T?): Mono<T> = - Mono.justOrEmpty(mapper(input)) + private fun <T, V>omitWhenNull(input: T, mapper: (T) -> V?): Mono<V> = Mono.justOrEmpty(mapper(input)) private fun <T>releaseWhenNull(input: ByteBuf, mapper: (ByteBuf) -> T?): Mono<T> { val result = mapper(input) |