2014년 12월 25일 목요일

Error Handing in 3.0 async driver

I am initialising the driver with write concern acknowledged


MongoClientOptions options = MongoClientOptions.newInstance().builder()
        .writeConcern(WriteConcern.ACKNOWLEDGED)
        .connectionPoolSettings(ConnectionPoolSettings.builder().applyConnectionString(mongoURL).build())
this.mongoClient = MongoClients.create(options)

I am issuing an insert against the db with an id that already exists (in groovy):


try {
    System.out.println('calling insertOne') // this gets called
    collection.insertOne(document, { ->
        System.out.println('inserted') // this is never reached
    } as SingleResultCallback)
} catch(Throwable t) {
    System.out.println(' found exception: ' + t) // this is never reached
}

In that case I would expect to see a MongoException or a MongoWriteException, however no error is returned. 

I can change the closure to accept parameters, but that does not change anything.

I can even try it the java way:


try {
    System.out.println('calling insertOne')  // this gets called
    collection.insertOne(document, new SingleResultCallback<Void>() {
        @Override
        void onResult(Void result, Throwable t) {
            System.out.println('result: ' + result + ' t: ' + t) // this is never reached
        }
    })
} catch(Throwable t) {
    System.out.println(' found exception: ' + t) // this is never reached
}
Is this an error on my side, or might this be a bug?



It's an error on the driver side, so thanks for reporting it.  I reported it as https://jira.mongodb.org/browse/JAVA-1604 and it's fixed in the latest SNAPSHOT release.


댓글 없음:

댓글 쓰기