详细报错如下:
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]
报错的位置:
原因:
库中n是Double类型
此处类型转换异常
关于 chunks.n
正常情况下库中n是Int32