详细报错如下:

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_mongodb

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
    at org.bson.Document.getInteger(Document.java:244) ~[bson-4.0.4.jar:na]
    at com.mongodb.client.gridfs.GridFSDownloadStreamImpl.getChunk(GridFSDownloadStreamImpl.java:223) ~[mongodb-driver-sync-4.0.4.jar:na]
    at com.mongodb.client.gridfs.GridFSDownloadStreamImpl.getBuffer(GridFSDownloadStreamImpl.java:277) ~[mongodb-driver-sync-4.0.4.jar:na]
    at com.mongodb.client.gridfs.GridFSDownloadStreamImpl.read(GridFSDownloadStreamImpl.java:101) ~[mongodb-driver-sync-4.0.4.jar:na]
    at com.mongodb.client.gridfs.GridFSDownloadStreamImpl.read(GridFSDownloadStreamImpl.java:91) ~[mongodb-driver-sync-4.0.4.jar:na]
    at com.mongodb.client.gridfs.GridFSDownloadStreamImpl.read(GridFSDownloadStreamImpl.java:82) ~[mongodb-driver-sync-4.0.4.jar:na]

报错的位置:

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_mongodb_02

原因:

库中n是Double类型

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_java_03

此处类型转换异常 

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_java_04

 关于 chunks.n

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_java_05

 正常情况下库中n是Int32 

MongoDB java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer_java_06