Repository: quarkusio/quarkus
Issue: Quarkus Mongodb change stream resume token always null in native

## Describe the bug

I'm building a quarkus app that uses the mongodb change streams functionality with the reactive client.

If I start the application locally from Intellij everything works fine but when I build the native app and try to save the resume token it's always null.

I use this command to build the native app since I need to build it locally on windows and delpoy it on heroku:

    mvn package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:21.0.0-java11

This is the class and method where I initialize the change stream and start the watch on the collection

    @Inject
    ReactiveMongoClient mongoClient;
    
    private void initOrderStream() {
        ReactiveMongoDatabase database = mongoClient.getDatabase("database");
        ReactiveMongoCollection<Order> dataCollection = database.getCollection("order", Order.class);
        ChangeStreamOptions options = new ChangeStreamOptions().fullDocument(FullDocument.UPDATE_LOOKUP);


        List<Bson> pipeline = Collections.singletonList(
                Aggregates.match(
                        Filters.and(
                                Filters.eq("operationType", "insert")
                        )
                )
        );

        Multi<ChangeStreamDocument<Order>> publisher = dataCollection.watch(pipeline, Order.class, options);
        publisher.subscribe().with(eventListener.getOrderListener());
    }


And this is the listener method

    public Consumer<ChangeStreamDocument<Order>> getOrderListener() {
        return message -> {
            logger.info("Saving resume token for message " + message);
            EventConfig eventConfig = new EventConfig();
            eventConfig.setType(eventType);
            eventConfig.setResumeToken(message.getResumeToken().getString("_data"));
            EventConfig.persistOrUpdate(eventConfig);

    	    Order order = message.getFullDocument();
    	    saveEvent(order);
        };
    }

The problem is in the message.getResumeToken() method, if I start the application non native than the resume token is present and I can save it without problems, but when I build it native and put it in a container the resume token is always null.

Without resume token the change streams are almost useless since Iit's not possible to recover missing events if a problem occurs or appplication needs to be restarted.

### Expected behavior
The resume token using the _getResumeToken_ method of the ChangeStreamDocument class should not return null in native mode.

### Actual behavior
The resume token using the _getResumeToken_ method of the ChangeStreamDocument class is always null in native mode.


## To Reproduce

Steps to reproduce the behavior:
1. Create a quarkus app 
2. Connect it to mongodb 
3. Initialize change stream on a collection using the code mentioned above
4. Package the application in native mode using the maven command above
5. Start the application
4. Insert a document in the collection attached to the watcher and receive a null pointer exception because the resume token is null


## Environment (please complete the following information):

### Output of `java -version`
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)

### Quarkus version or git rev
1.13.6.Final


Changed files:
extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java

diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
index 8e39a69b417..3eb4fd9546e 100644
--- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
+++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
@@ -135,11 +135,13 @@ List<ReflectiveClassBuildItem> addExtensionPointsToNative(CodecProviderBuildItem
         reflectiveClassNames.addAll(propertyCodecProviders.getPropertyCodecProviderClassNames());
         reflectiveClassNames.addAll(bsonDiscriminators.getBsonDiscriminatorClassNames());
         reflectiveClassNames.addAll(commandListeners.getCommandListenerClassNames());
-        reflectiveClassNames.add(ChangeStreamDocument.class.getName());
 
-        return reflectiveClassNames.stream()
+        List<ReflectiveClassBuildItem> reflectiveClass = reflectiveClassNames.stream()
                 .map(s -> new ReflectiveClassBuildItem(true, true, false, s))
-                .collect(Collectors.toList());
+                .collect(Collectors.toCollection(() -> new ArrayList<>()));
+        // ChangeStreamDocument needs to be registered for reflection with its fields.
+        reflectiveClass.add(new ReflectiveClassBuildItem(true, true, true, ChangeStreamDocument.class.getName()));
+        return reflectiveClass;
     }
 
     @BuildStep