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

MongoDB Client Extension - NullPointerException in native mode with ChangeStreamDocumentCodec #17432

Closed
JiriOndrusek opened this issue May 24, 2021 · 1 comment · Fixed by #17433
Assignees
Labels
area/mongodb kind/bug Something isn't working
Milestone

Comments

@JiriOndrusek
Copy link
Contributor

JiriOndrusek commented May 24, 2021

Describe the bug

MongoDb client does not contain registration for reflection of ChangeStreamDocument. Therefore it causes NPE in https://github.com/mongodb/mongo-java-driver/blob/master/driver-core/src/main/com/mongodb/client/model/changestream/ChangeStreamDocumentCodec.java#L44

To Reproduce

You can use camel-quarkus and its test. Following change has to be present - apache/camel-quarkus#2642
Then you have to:

  1. Remove workaround of this issue, be removing method MongoDbProcessor.reflectiveClass (https://github.com/apache/camel-quarkus/pull/2642/files#diff-a69e11de2fa675737)
  2. Run tests from module integration-tests/mongodb in native mode. You can use command mvn clean verify -Pnative -f integration-tests/mongodb
    Following exception should happen:
2021-05-24 12:06:36,062 ERROR [org.apa.cam.imp.eng.AbstractCamelContext] (main) Error starting CamelContext (camel-1) due to exception thrown: null: java.lang.NullPointerException
	at com.mongodb.client.model.changestream.ChangeStreamDocumentCodec.<init>(ChangeStreamDocumentCodec.java:45)
	at com.mongodb.client.model.changestream.ChangeStreamDocument.createCodec(ChangeStreamDocument.java:296)
	at com.mongodb.client.internal.ChangeStreamIterableImpl.<init>(ChangeStreamIterableImpl.java:84)
	at com.mongodb.client.internal.MongoCollectionImpl.createChangeStreamIterable(MongoCollectionImpl.java:380)
	at com.mongodb.client.internal.MongoCollectionImpl.watch(MongoCollectionImpl.java:352)
	at com.mongodb.client.internal.MongoCollectionImpl.watch(MongoCollectionImpl.java:347)
	at org.apache.camel.component.mongodb.MongoDbChangeStreamsThread.initializeCursor(MongoDbChangeStreamsThread.java:51)
	at org.apache.camel.component.mongodb.MongoDbChangeStreamsThread.init(MongoDbChangeStreamsThread.java:45)
	at org.apache.camel.component.mongodb.MongoDbChangeStreamsConsumer.doStart(MongoDbChangeStreamsConsumer.java:69)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
	at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113)
	at org.apache.camel.impl.engine.AbstractCamelContext.startService(AbstractCamelContext.java:3474)
	at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRouteConsumers(InternalRouteStartupManager.java:401)
	at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartRouteConsumers(InternalRouteStartupManager.java:319)
	at org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:213)
	at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147)
	at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3177)
	at org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:2861)
	at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2812)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2507)
	at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
	at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:139)
	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy_0(CamelBootstrapProcessor$boot-173480958.zig:101)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy(CamelBootstrapProcessor$boot-173480958.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:763)
	at io.quarkus.runtime.Application.start(Application.java:90)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)

Quarkus version:
Running Quarkus native-image plugin on GraalVM Version 21.0.0.2 (Java Version 11.0.10+8-LTS-jvmci-21.0-b06)

@JiriOndrusek JiriOndrusek added the kind/bug Something isn't working label May 24, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented May 24, 2021

/cc @evanchooly, @loicmathieu

geoand added a commit to geoand/quarkus that referenced this issue May 24, 2021
@geoand geoand self-assigned this May 24, 2021
gsmet added a commit that referenced this issue May 24, 2021
Add ChangeStreamDocument Mongo class for reflection
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 24, 2021
@gsmet gsmet modified the milestones: 2.0 - main, 1.13.5.Final May 25, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mongodb kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants