From 3029de217adadaec275e8393a659ac4566d925b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCller?= <449563+steffenmllr@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:13:22 +0100 Subject: [PATCH] Fix Nullpointer on empty auction context (#3618) --- .../reporter/agma/AgmaAnalyticsReporter.java | 7 ++++++- .../reporter/agma/AgmaAnalyticsReporterTest.java | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java index 9c3252d4116..ed99c241ee5 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java @@ -116,6 +116,11 @@ public Future processEvent(T event) { } final AuctionContext auctionContext = contextAndType.getLeft(); + final String eventType = contextAndType.getRight(); + if (auctionContext == null) { + return Future.succeededFuture(); + } + final BidRequest bidRequest = auctionContext.getBidRequest(); final TimeoutContext timeoutContext = auctionContext.getTimeoutContext(); final PrivacyContext privacyContext = auctionContext.getPrivacyContext(); @@ -134,7 +139,7 @@ public Future processEvent(T event) { } final AgmaEvent agmaEvent = AgmaEvent.builder() - .eventType(contextAndType.getRight()) + .eventType(eventType) .accountCode(accountCode) .requestId(bidRequest.getId()) .app(bidRequest.getApp()) diff --git a/src/test/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporterTest.java b/src/test/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporterTest.java index 3de67e31b93..e7ce7126031 100644 --- a/src/test/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporterTest.java +++ b/src/test/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporterTest.java @@ -109,6 +109,21 @@ public void setUp() { target = new AgmaAnalyticsReporter(properties, versionProvider, jacksonMapper, clock, httpClient, vertx); } + @Test + public void processEventShouldNotSendAnythingWhenAuctionContextIsNull() { + // given + final AuctionEvent auctionEvent = AuctionEvent.builder() + .auctionContext(null) + .build(); + + // when + final Future result = target.processEvent(auctionEvent); + + // then + verifyNoInteractions(httpClient); + assertThat(result.succeeded()).isTrue(); + } + @Test public void processEventShouldSendEventWhenEventIsAuctionEvent() { // given