阅读 74

MongoDB java.lang.Double cannot be cast to java.lang.Integer

详细报错如下:

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]
复制代码

image.png

报错的位置:

image.png

原因:

库中n是Double类型

image.png

此处类型转换异常

image.png

关于 chunks.n

image.png

正常情况下库中n是Int32

image.png

文章分类
后端
文章标签