Ticket : Projection| Not able to cast document to list

When I run projection test, I am getting this exception -
java.lang.ClassCastException: org.bson.Document cannot be cast to java.util.List

My search query is returning documents into a list “movies”. Here is the screenshot of code snippet. Don’t know what’s happening. What I need to do to correct this ? Please help

Hi @Sparsh_94744,

Your code and logic is absolutely correct. Just one thing, when you are doing: movies = <CODE>..tryNext(), it is assigning current movie document (and not list) to movies variable. If you need to add the documents into a list, try following code:

   .forEachRemaining(movies::add); 

Kanika