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

Fix PG intersects expression to avoid NPE #1693

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

rpanchyk
Copy link
Contributor

@rpanchyk rpanchyk commented Jan 19, 2022

This PR fixes NullPointerException:

ERROR [ntloop-thread-4] o.p.s.handler.openrtb2.AuctionHandler : Critical error while running the auction
java.lang.NullPointerException: null
at org.prebid.server.deals.targeting.interpret.IntersectsStrings.toLowerCase(IntersectsStrings.java:23)
at org.prebid.server.deals.targeting.interpret.IntersectsStrings.lookupActualValues(IntersectsStrings.java:19)
at org.prebid.server.deals.targeting.interpret.Intersects.matches(Intersects.java:25)
at org.prebid.server.deals.targeting.interpret.And.matches(And.java:21)
at org.prebid.server.deals.TargetingService.matchesTargeting(TargetingService.java:70)

It was occurred when FPD is not defined in request:

"site": {
  "publisher": {
    "id": "ACCOUNT"
  }

Until adding site FPD:

"site": {
  "publisher": {
    "id": "ACCOUNT"
  },
  "ext": {
    "data": {
      "key1": [ "value" ]
    }
  }
}

For PG targeting like:

"sfpd.key1": {
    "$intersects": [
        "value",
        "value2"
    ]
}

@rpanchyk rpanchyk requested review from And1sS and hupaloo January 19, 2022 18:50
@@ -16,7 +16,8 @@ public IntersectsStrings(TargetingCategory category, List<String> values) {

@Override
public List<String> lookupActualValues(RequestContext context) {
return toLowerCase(context.lookupStrings(category));
final List<String> values = context.lookupStrings(category);
return values != null ? toLowerCase(values) : null;
Copy link
Member

Choose a reason for hiding this comment

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

Why not return Collections.emptyList() here and leave previous implementation of matches?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NULL is more optimized. If look forward in org.prebid.server.deals.targeting.interpret.Intersects#matches method - the call of Collections.disjoint(..) is not required. Another though - lookupActualValues(..) method returns values in request, so empty list can real value.

@rpanchyk rpanchyk merged commit 76f4d95 into master Jan 20, 2022
@rpanchyk rpanchyk deleted the fix/pg-intersects-expression-npe branch January 20, 2022 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants