[JAVA-2936] Aggregates#lookup method uses wrong generic type parameter for Variable Created: 21/Aug/18  Updated: 28/Oct/23  Resolved: 22/Aug/18

Status: Closed
Project: Java Driver
Component/s: API, Builders
Affects Version/s: None
Fix Version/s: 3.9.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Minor Change

 Description   

The current signature for one of the overloads of Aggregates#lookup is:

public static Bson lookup(final String from,
                                        @Nullable final List<Variable<?>> let, 
                                        final List<? extends Bson> pipeline,
                                        final String as)

But the "let" parameter type is incorrect. Using a wildcard for the generic type of Variable effectively means that you can only pass a null list for this parameter.

The method should instead be defined as

public static <TExpression> 
                    Bson lookup(final String from,
                                        @Nullable final List<Variable<TExpression>> let, 
                                        final List<? extends Bson> pipeline,
                                        final String as)



 Comments   
Comment by Githook User [ 22/Aug/18 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}

Message: JAVA-2936: Fix signature of Aggregates.lookup overload.

The signature of the lookup method with a parameter for "let" is
incorrect. Instead of

List<Variable<?>>

it should be

List<Variable<TExpression>>

where TExpression is a method-level type parameter. Otherwise, the only
value you can pass to it is null.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8d4ee27b9e288135615810ef21b10a49d5756a2a

Generated at Thu Feb 08 08:58:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.