Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AGMA: Fix Nullpointer on empty auction context #3618

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public <T> Future<Void> processEvent(T event) {
}

final AuctionContext auctionContext = contextAndType.getLeft();
final String eventType = contextAndType.getRight();
if (auctionContext == null) {
return Future.succeededFuture();
}
Comment on lines +120 to +122
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I know the case when auctionContext is null, because it should always be created for each auction

What's the case you've face to make this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntoxaAntoxic as stated in the ticket this happens if a request tries to access a storedrequest that does not exist

grafik

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does lead to this nullpointer:

prebid-server-1  | java.lang.NullPointerException: Cannot invoke "org.prebid.server.auction.model.AuctionContext.getBidRequest()" because "auctionContext" is null
prebid-server-1  | 	at org.prebid.server.analytics.reporter.agma.AgmaAnalyticsReporter.processEvent(AgmaAnalyticsReporter.java:119)
prebid-server-1  | 	at org.prebid.server.analytics.reporter.AnalyticsReporterDelegator.processEventByReporter(AnalyticsReporterDelegator.java:355)
prebid-server-1  | 	at org.prebid.server.analytics.reporter.AnalyticsReporterDelegator.lambda$delegateEvent$2(AnalyticsReporterDelegator.java:133)
prebid-server-1  | 	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
prebid-server-1  | 	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:261)
prebid-server-1  | 	at io.vertx.core.impl.ContextInternal.lambda$runOnContext$0(ContextInternal.java:59)
prebid-server-1  | 	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
prebid-server-1  | 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
prebid-server-1  | 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
prebid-server-1  | 	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413)
prebid-server-1  | 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
prebid-server-1  | 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
prebid-server-1  | 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
prebid-server-1  | 	at java.base/java.lang.Thread.run(Thread.java:1583)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've skipped the description)

Yeah, I see. Interesting.


final BidRequest bidRequest = auctionContext.getBidRequest();
final TimeoutContext timeoutContext = auctionContext.getTimeoutContext();
final PrivacyContext privacyContext = auctionContext.getPrivacyContext();
Expand All @@ -134,7 +139,7 @@ public <T> Future<Void> processEvent(T event) {
}

final AgmaEvent agmaEvent = AgmaEvent.builder()
.eventType(contextAndType.getRight())
.eventType(eventType)
.accountCode(accountCode)
.requestId(bidRequest.getId())
.app(bidRequest.getApp())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> result = target.processEvent(auctionEvent);

// then
verifyNoInteractions(httpClient);
assertThat(result.succeeded()).isTrue();
}

@Test
public void processEventShouldSendEventWhenEventIsAuctionEvent() {
// given
Expand Down
Loading