aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org/onap
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2023-06-21 16:45:47 +0100
committerToineSiebelink <toine.siebelink@est.tech>2023-06-21 17:01:18 +0100
commit57cceb2b3d680363719bda3204c24d93fd93f64f (patch)
treea6c558a0b21ed11648dce417e48024ea1bbd6d13 /cps-ncmp-service/src/main/java/org/onap
parentaadbac4706a906252083ade06621db38a73fb343 (diff)
Improve handling of legacy events
Legacy (non-cloud) events would cause a NPE in the event filter Although the event woudl still be ignored it would lead to uncessary error logging This fix addressed this issue using a trace level message instead (also some improvements in the associated test) Issue-ID: CPS-1724 Signed-off-by: ToineSiebelink <toine.siebelink@est.tech> Change-Id: Ibf71b13e4a47aaf705e32df5fe50cf41de5f558f
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationRecordFilterStrategy.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationRecordFilterStrategy.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationRecordFilterStrategy.java
index ce666b109..76cc0c4b7 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationRecordFilterStrategy.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationRecordFilterStrategy.java
@@ -22,6 +22,7 @@ package org.onap.cps.ncmp.api.impl.async;
import io.cloudevents.CloudEvent;
import io.cloudevents.kafka.impl.KafkaHeaders;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.listener.adapter.RecordFilterStrategy;
@@ -31,6 +32,7 @@ import org.springframework.kafka.listener.adapter.RecordFilterStrategy;
*
*/
@Configuration
+@Slf4j
public class DataOperationRecordFilterStrategy {
/**
@@ -42,8 +44,11 @@ public class DataOperationRecordFilterStrategy {
@Bean
public RecordFilterStrategy<String, CloudEvent> includeDataOperationEventsOnly() {
return consumedRecord -> {
- final String eventTypeHeaderValue = KafkaHeaders.getParsedKafkaHeader(
- consumedRecord.headers(), "ce_type");
+ final String eventTypeHeaderValue = KafkaHeaders.getParsedKafkaHeader(consumedRecord.headers(), "ce_type");
+ if (eventTypeHeaderValue == null) {
+ log.trace("No ce_type header found, possibly a legacy event (ignored)");
+ return true;
+ }
return !(eventTypeHeaderValue.contains("DataOperationEvent"));
};
}