[JAVA-3500] NullPointerException in org.bson.codecs.Encoder.encode is swallowed Created: 04/Nov/19  Updated: 11/Oct/21  Resolved: 12/Nov/19

Status: Closed
Project: Java Driver
Component/s: Async
Affects Version/s: 3.11.1
Fix Version/s: None

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

Issue Links:
Duplicate

 Description   

I have a class that implements Codec<T>. In the `encode` method there was a NPE thrown but there was nothing in the logs. It took me a few hours to figure it out. That should be fixed so other people are not hit by this like me.

I'm using the latest version of the async Java driver.



 Comments   
Comment by Boris Petrov [ 12/Nov/19 ]

You're welcome! And thank you for the great and fast support!

Comment by Jeffrey Yemin [ 12/Nov/19 ]

Nope, you can delete it. Thanks again!

Comment by Boris Petrov [ 12/Nov/19 ]

Great, I'm glad you found the problem!

Do you still need the reproduction repo or I can delete it?

Comment by Jeffrey Yemin [ 12/Nov/19 ]

This is a reactive streams bug, so we've opened JAVARS-220 to track it.

Thanks for the report.

Comment by Boris Petrov [ 11/Nov/19 ]

Here is a demo repo:

https://github.com/boris-petrov/mongo-java-driver-bug

Just clone it and run `gradle run` in it. I'm testing with Gradle 5.6.x. If that works on your side... I don't know. I tested with both Java 12 and Java 13 - the behavior is incorrect in both cases on my side - on Arch Linux and on Ubuntu.

Comment by Jeffrey Yemin [ 11/Nov/19 ]

I'm not sure what the difference is. I'm using the same versions of everything (except Java, which is 11). Maybe put a full project up on Github and I can download it?

Comment by Boris Petrov [ 11/Nov/19 ]

OK, now that's strange. This is my setup:

%  java --version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode)

Running on Arch Linux. I run the program using this command line:

java -cp mongodb-driver-async-3.11.0.jar:reactive-streams-1.0.3.jar:mongodb-driver-reactivestreams-1.12.0.jar:bson-3.11.0.jar:mongodb-driver-core-3.11.0.jar A.java

What is different on your system? This is the full output:

%  java -cp mongodb-driver-async-3.11.0.jar:reactive-streams-1.0.3.jar:mongodb-driver-reactivestreams-1.12.0.jar:bson-3.11.0.jar:mongodb-driver-core-3.11.0.jar A.java
Nov 11, 2019 4:21:28 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Nov 11, 2019 4:21:29 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: No server chosen by com.mongodb.async.client.ClientSessionHelper$1@74bf1791 from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
Nov 11, 2019 4:21:29 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:1, serverValue:5}] to 127.0.0.1:27017
Nov 11, 2019 4:21:29 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Monitor thread successfully connected to server with description ServerDescription{address=127.0.0.1:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 1]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=4811258}
Nov 11, 2019 4:21:29 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:2, serverValue:6}] to 127.0.0.1:27017
1111
Completed successfully. Unexpected, should error.

Comment by Jeffrey Yemin [ 11/Nov/19 ]

I don't reproduce that result. I get this output:

1111
Completed with error.  Expected result
java.lang.NullPointerException
	at java3500.ReactiveStreamsExample$StringCodec.encode(ReactiveStreamsExample.java:50)
	at java3500.ReactiveStreamsExample$StringCodec.encode(ReactiveStreamsExample.java:35)
	at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
	at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:185)
	at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:199)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:141)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
        ...

Comment by Boris Petrov [ 11/Nov/19 ]

Thank you for the example and sorry for the delayed answer. A simple change to your program:

 

        public void encode(final BsonWriter writer, String value, final EncoderContext encoderContext) {
            if (value.equals("42")) {
                value = null;
            }
            System.err.println(1111);
            System.err.println(value.toString());
            System.err.println(2222);
            writer.writeString(value);
        }

Causes the example program to write this to `stderr`:

1111
Completed successfully. Unexpected, should error.

I'm not sure why it matters what kind of exception it is, but as you see, a NPE causes a problem as the error handler is not called and nothing is logged.

 

Comment by Jeffrey Yemin [ 06/Nov/19 ]

Closing for now. Please comment back if you still suspect that this is a driver bug.

Comment by Jeffrey Yemin [ 06/Nov/19 ]

I was not able to reproduce using a simple test program using the reactive streams driver

import com.mongodb.MongoClientSettings;
import com.mongodb.reactivestreams.client.MongoClients;
import com.mongodb.reactivestreams.client.Success;
import org.bson.BsonReader;
import org.bson.BsonWriter;
import org.bson.Document;
import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.bson.codecs.configuration.CodecRegistries;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
 
public class ReactiveStreamsExample {
 
    static class StringCodec implements Codec<String> {
        @Override
        public String decode(final BsonReader reader, final DecoderContext decoderContext) {
            return reader.readString();
        }
 
        @Override
        public void encode(final BsonWriter writer, final String value, final EncoderContext encoderContext) {
            if (value.equals("42")) {
                throw new UnsupportedOperationException();
            }
            writer.writeString(value);
        }
 
        @Override
        public Class<String> getEncoderClass() {
            return String.class;
        }
    }
 
    public static void main(String[] args) throws InterruptedException {
        var registry =
                CodecRegistries.fromRegistries(
                        CodecRegistries.fromCodecs(new StringCodec()),
                        MongoClientSettings.getDefaultCodecRegistry()
                );
 
        var client = MongoClients.create(
                MongoClientSettings.builder()
                        .codecRegistry(registry)
                        .build());
 
        var collection = client.getDatabase("test").getCollection("java3501");
 
        collection.insertOne(new Document("bad", "42")).subscribe(new Subscriber<>() {
            @Override
            public void onSubscribe(final Subscription s) {
                s.request(1);
            }
 
            @Override
            public void onNext(final Success success) {
                System.out.println("Next... Unexpected, should error");
            }
 
            @Override
            public void onError(final Throwable t) {
                System.out.println("Completed with error.  Expected result");
                t.printStackTrace();
            }
 
            @Override
            public void onComplete() {
                System.out.println("Completed successfully. Unexpected, should error.");
            }
        });
 
        Thread.sleep(10000);
    }
}

I suspect this is a problem with your application, not with the driver. I suggest you double check your error handling. With reactive applications, exceptions are not processed in the usual way, as they're not thrown and caught like in synchronous applications.

Comment by Boris Petrov [ 06/Nov/19 ]

For now can I give you a stacktrace - maybe you can figure out from it why there is no notification? If not, do you have some sample project that I can modify to reproduce the issue?

java.lang.NullPointerException: null
    at com.company.BaseCodecProvider$ImmediateValueCodec.encode(BaseCodecProvider.java:211)
    at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
    at org.bson.codecs.IterableCodec.writeValue(IterableCodec.java:106)
    at org.bson.codecs.IterableCodec.encode(IterableCodec.java:90)
    at org.bson.codecs.IterableCodec.encode(IterableCodec.java:37)
    at org.bson.codecs.EncoderContext.encodeWithChildContext(EncoderContext.java:91)
    at com.company.codecs.BaseCodec.writeValue(BaseCodec.java:34)
    at com.company.BaseCodecProvider$BaseCodec.encode(BaseCodecProvider.java:250)
    at com.company.BaseCodecProvider$BaseCodec.encode(BaseCodecProvider.java:235)
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
    at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:385)
    at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:375)
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
    at com.mongodb.internal.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:75)
    at com.mongodb.internal.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:59)
    at com.mongodb.internal.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:147)
    at com.mongodb.internal.connection.RequestMessage.encode(RequestMessage.java:138)
    at com.mongodb.internal.connection.CommandMessage.encode(CommandMessage.java:61)
    at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceiveAsync(InternalStreamConnection.java:329)
    at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceiveAsync(UsageTrackingInternalConnection.java:114)
    at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceiveAsync(DefaultConnectionPool.java:461)
    at com.mongodb.internal.connection.CommandProtocolImpl.executeAsync(CommandProtocolImpl.java:78)
    at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.executeAsync(DefaultServer.java:233)
    at com.mongodb.internal.connection.DefaultServerConnection.executeProtocolAsync(DefaultServerConnection.java:285)
    at com.mongodb.internal.connection.DefaultServerConnection.commandAsync(DefaultServerConnection.java:156)
    at com.mongodb.operation.MixedBulkWriteOperation.executeCommandAsync(MixedBulkWriteOperation.java:444)
    at com.mongodb.operation.MixedBulkWriteOperation.executeBatchesAsync(MixedBulkWriteOperation.java:350)
    at com.mongodb.operation.MixedBulkWriteOperation.access$1000(MixedBulkWriteOperation.java:72)
    at com.mongodb.operation.MixedBulkWriteOperation$2$1.call(MixedBulkWriteOperation.java:239)
    at com.mongodb.operation.OperationHelper.validateWriteRequests(OperationHelper.java:189)
    at com.mongodb.operation.MixedBulkWriteOperation$2.call(MixedBulkWriteOperation.java:222)
    at com.mongodb.operation.OperationHelper$7.onResult(OperationHelper.java:614)
    at com.mongodb.operation.OperationHelper$7.onResult(OperationHelper.java:611)
    at com.mongodb.internal.connection.DefaultServer$1.onResult(DefaultServer.java:116)
    at com.mongodb.internal.connection.DefaultServer$1.onResult(DefaultServer.java:105)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.internal.connection.DefaultConnectionPool.openAsync(DefaultConnectionPool.java:201)
    at com.mongodb.internal.connection.DefaultConnectionPool.getAsync(DefaultConnectionPool.java:158)
    at com.mongodb.internal.connection.DefaultServer.getConnectionAsync(DefaultServer.java:105)
    at com.mongodb.binding.AsyncClusterBinding$AsyncClusterBindingConnectionSource.getConnection(AsyncClusterBinding.java:139)
    at com.mongodb.operation.OperationHelper.withAsyncConnectionSource(OperationHelper.java:611)
    at com.mongodb.operation.OperationHelper.access$200(OperationHelper.java:63)
    at com.mongodb.operation.OperationHelper$AsyncCallableWithConnectionAndSourceCallback.onResult(OperationHelper.java:631)
    at com.mongodb.operation.OperationHelper$AsyncCallableWithConnectionAndSourceCallback.onResult(OperationHelper.java:619)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:113)
    at com.mongodb.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:107)
    at com.mongodb.internal.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:436)
    at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:300)
    at com.mongodb.internal.connection.BaseCluster.selectServerAsync(BaseCluster.java:160)
    at com.mongodb.internal.connection.SingleServerCluster.selectServerAsync(SingleServerCluster.java:41)
    at com.mongodb.binding.AsyncClusterBinding.getAsyncClusterBindingConnectionSource(AsyncClusterBinding.java:107)
    at com.mongodb.binding.AsyncClusterBinding.getWriteConnectionSource(AsyncClusterBinding.java:102)
    at com.mongodb.operation.OperationHelper.withAsyncConnection(OperationHelper.java:550)
    at com.mongodb.operation.MixedBulkWriteOperation.executeAsync(MixedBulkWriteOperation.java:216)
    at com.mongodb.async.client.OperationExecutorImpl$2$1.onResult(OperationExecutorImpl.java:134)
    at com.mongodb.async.client.OperationExecutorImpl$2$1.onResult(OperationExecutorImpl.java:128)
    at com.mongodb.async.client.OperationExecutorImpl.getReadWriteBinding(OperationExecutorImpl.java:186)
    at com.mongodb.async.client.OperationExecutorImpl.access$200(OperationExecutorImpl.java:45)
    at com.mongodb.async.client.OperationExecutorImpl$2.onResult(OperationExecutorImpl.java:126)
    at com.mongodb.async.client.OperationExecutorImpl$2.onResult(OperationExecutorImpl.java:120)
    at com.mongodb.async.client.ClientSessionHelper$2.onResult(ClientSessionHelper.java:80)
    at com.mongodb.async.client.ClientSessionHelper$2.onResult(ClientSessionHelper.java:73)
    at com.mongodb.internal.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:436)
    at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:300)
    at com.mongodb.internal.connection.BaseCluster.selectServerAsync(BaseCluster.java:160)
    at com.mongodb.internal.connection.SingleServerCluster.selectServerAsync(SingleServerCluster.java:41)
    at com.mongodb.async.client.ClientSessionHelper.createClientSession(ClientSessionHelper.java:68)
    at com.mongodb.async.client.ClientSessionHelper.withClientSession(ClientSessionHelper.java:51)
    at com.mongodb.async.client.OperationExecutorImpl.execute(OperationExecutorImpl.java:120)
    at com.mongodb.async.client.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1122)
    at com.mongodb.async.client.MongoCollectionImpl.executeInsertOne(MongoCollectionImpl.java:491)
    at com.mongodb.async.client.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:474)
    at com.mongodb.reactivestreams.client.internal.MongoCollectionImpl$8.apply(MongoCollectionImpl.java:432)
    at com.mongodb.reactivestreams.client.internal.MongoCollectionImpl$8.apply(MongoCollectionImpl.java:429)
    at com.mongodb.async.client.SingleResultCallbackSubscription.requestInitialData(SingleResultCallbackSubscription.java:38)
    at com.mongodb.async.client.AbstractSubscription.tryRequestInitialData(AbstractSubscription.java:170)
    at com.mongodb.async.client.AbstractSubscription.request(AbstractSubscription.java:88)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1$1.request(ObservableToPublisher.java:48)
    at io.reactivex.internal.operators.completable.CompletableFromPublisher$FromPublisherSubscriber.onSubscribe(CompletableFromPublisher.java:52)
    at com.mongodb.reactivestreams.client.internal.SingleResultObservableToPublisher$1.onSubscribe(SingleResultObservableToPublisher.java:37)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1.onSubscribe(ObservableToPublisher.java:37)
    at com.mongodb.async.client.SingleResultCallbackSubscription.<init>(SingleResultCallbackSubscription.java:33)
    at com.mongodb.async.client.Observables$2.subscribe(Observables.java:78)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher.subscribe(ObservableToPublisher.java:34)
    at com.mongodb.reactivestreams.client.internal.SingleResultObservableToPublisher.subscribe(SingleResultObservableToPublisher.java:34)
    at io.reactivex.internal.operators.completable.CompletableFromPublisher.subscribeActual(CompletableFromPublisher.java:32)
    at io.reactivex.Completable.subscribe(Completable.java:2309)
    at io.reactivex.Completable.subscribe(Completable.java:2383)
    at com.company.Mongo.lambda$getCompletable$3(Mongo.java:69)
    at io.reactivex.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:39)
    at io.reactivex.Completable.subscribe(Completable.java:2309)
    at io.reactivex.internal.operators.completable.CompletableToSingle.subscribeActual(CompletableToSingle.java:38)
    at io.reactivex.Single.subscribe(Single.java:3666)
    at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
    at io.reactivex.Single.subscribe(Single.java:3666)
    at io.reactivex.internal.operators.single.SingleToObservable.subscribeActual(SingleToObservable.java:35)
    at io.reactivex.Observable.subscribe(Observable.java:12267)
    at io.reactivex.internal.operators.mixed.SingleFlatMapObservable$FlatMapObserver.onSuccess(SingleFlatMapObservable.java:109)
    at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
    at io.reactivex.internal.operators.observable.ObservableToListSingle$ToListObserver.onComplete(ObservableToListSingle.java:111)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.drainLoop(ObservableFlatMap.java:371)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.drain(ObservableFlatMap.java:326)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onComplete(ObservableFlatMap.java:303)
    at io.reactivex.internal.observers.BasicFuseableObserver.onComplete(BasicFuseableObserver.java:119)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.drainLoop(ObservableFlatMap.java:371)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.drain(ObservableFlatMap.java:326)
    at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onComplete(ObservableFlatMap.java:584)
    at io.reactivex.internal.observers.BasicFuseableObserver.onComplete(BasicFuseableObserver.java:119)
    at io.reactivex.internal.observers.BasicFuseableObserver.onComplete(BasicFuseableObserver.java:119)
    at io.reactivex.internal.operators.mixed.SingleFlatMapObservable$FlatMapObserver.onComplete(SingleFlatMapObservable.java:79)
    at io.reactivex.internal.disposables.EmptyDisposable.complete(EmptyDisposable.java:53)
    at io.reactivex.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:50)
    at io.reactivex.Observable.subscribe(Observable.java:12267)
    at io.reactivex.internal.operators.mixed.SingleFlatMapObservable$FlatMapObserver.onSuccess(SingleFlatMapObservable.java:109)
    at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
    at io.reactivex.internal.operators.single.SingleZipArray$ZipCoordinator.innerSuccess(SingleZipArray.java:119)
    at io.reactivex.internal.operators.single.SingleZipArray$ZipSingleObserver.onSuccess(SingleZipArray.java:170)
    at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
    at io.reactivex.internal.operators.maybe.MaybeToSingle$ToSingleMaybeSubscriber.onComplete(MaybeToSingle.java:96)
    at io.reactivex.internal.operators.maybe.MaybeMap$MapMaybeObserver.onComplete(MaybeMap.java:99)
    at io.reactivex.internal.operators.maybe.MaybeCreate$Emitter.onComplete(MaybeCreate.java:118)
    at com.company.Mongo.lambda$getMaybe$8(Mongo.java:81)
    at io.reactivex.internal.operators.maybe.MaybeCallbackObserver.onComplete(MaybeCallbackObserver.java:93)
    at io.reactivex.internal.operators.observable.ObservableSingleMaybe$SingleElementObserver.onComplete(ObservableSingleMaybe.java:98)
    at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onComplete(ObservableFromPublisher.java:46)
    at com.mongodb.reactivestreams.client.internal.SingleResultObservableToPublisher$1.onComplete(SingleResultObservableToPublisher.java:56)
    at com.mongodb.reactivestreams.client.internal.SingleResultObservableToPublisher$1.onError(SingleResultObservableToPublisher.java:48)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1.onError(ObservableToPublisher.java:71)
    at com.mongodb.async.client.AbstractSubscription.onError(AbstractSubscription.java:132)
    at com.mongodb.async.client.AbstractSubscription.tryProcessResultsQueue(AbstractSubscription.java:180)
    at com.mongodb.async.client.SingleResultCallbackSubscription$1.onResult(SingleResultCallbackSubscription.java:48)
    at com.mongodb.async.client.FindIterableImpl$1$1.onResult(FindIterableImpl.java:212)
    at com.mongodb.async.client.FindIterableImpl$1$1.onResult(FindIterableImpl.java:205)
    at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:174)
    at com.mongodb.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:118)
    at com.mongodb.async.client.FindIterableImpl$1.onResult(FindIterableImpl.java:205)
    at com.mongodb.async.client.FindIterableImpl$1.onResult(FindIterableImpl.java:199)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.async.client.OperationExecutorImpl$1$1$1.onResult(OperationExecutorImpl.java:94)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.operation.FindOperation$3.onResult(FindOperation.java:827)
    at com.mongodb.operation.OperationHelper$ReferenceCountedReleasingWrappedCallback.onResult(OperationHelper.java:412)
    at com.mongodb.operation.CommandOperationHelper$10.onResult(CommandOperationHelper.java:481)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor$2.onResult(DefaultServer.java:245)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.internal.connection.CommandProtocolImpl$1.onResult(CommandProtocolImpl.java:85)
    at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection$1.onResult(DefaultConnectionPool.java:467)
    at com.mongodb.internal.connection.UsageTrackingInternalConnection$2.onResult(UsageTrackingInternalConnection.java:111)
    at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:49)
    at com.mongodb.internal.connection.InternalStreamConnection$2$1.onResult(InternalStreamConnection.java:399)
    at com.mongodb.internal.connection.InternalStreamConnection$2$1.onResult(InternalStreamConnection.java:376)
    at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:677)
    at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:644)
    at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:514)
    at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:511)
    at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:220)
    at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:203)
    at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
    at java.base/sun.nio.ch.Invoker.invokeDirect(Invoker.java:158)
    at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.implRead(UnixAsynchronousSocketChannelImpl.java:562)
    at java.base/sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:277)
    at java.base/sun.nio.ch.AsynchronousSocketChannelImpl.read(AsynchronousSocketChannelImpl.java:298)
    at com.mongodb.internal.connection.AsynchronousSocketChannelStream$AsynchronousSocketChannelAdapter.read(AsynchronousSocketChannelStream.java:137)
    at com.mongodb.internal.connection.AsynchronousChannelStream.readAsync(AsynchronousChannelStream.java:105)
    at com.mongodb.internal.connection.InternalStreamConnection.readAsync(InternalStreamConnection.java:511)
    at com.mongodb.internal.connection.InternalStreamConnection.access$1000(InternalStreamConnection.java:76)
    at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback.onResult(InternalStreamConnection.java:634)
    at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback.onResult(InternalStreamConnection.java:619)
    at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:514)
    at com.mongodb.internal.connection.InternalStreamConnection$5.completed(InternalStreamConnection.java:511)
    at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:220)
    at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:203)
    at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
    at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:439)
    at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:191)
    at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
    at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:306)
    at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)

Comment by Jeffrey Yemin [ 05/Nov/19 ]

alien, a runnable example would be appreciated.

Comment by Boris Petrov [ 04/Nov/19 ]

Yes. It's definitely better to leave logging to the application. But (unless we have a bug somewhere) in this case this doesn't happen.

If you can't reproduce it with a simple example, please tell me and I'll try to provide such.

Comment by Jeffrey Yemin [ 04/Nov/19 ]

The driver should propagate the exception, but it doesn't generally log exceptions that it throws. It leaves that logging responsibility to the application. Are you saying that the exception is neither logged nor thrown?

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