提交 247b99f2 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: improved error message

上级 ddc1b4c9
...@@ -166,13 +166,17 @@ public class Page { ...@@ -166,13 +166,17 @@ public class Page {
long pos, long filePos, long fileSize) { long pos, long filePos, long fileSize) {
ByteBuffer buff; ByteBuffer buff;
int maxLength = DataUtils.getPageMaxLength(pos); int maxLength = DataUtils.getPageMaxLength(pos);
maxLength = (int) Math.min(fileSize - filePos, maxLength);
int length = maxLength;
if (maxLength == Integer.MAX_VALUE) { if (maxLength == Integer.MAX_VALUE) {
buff = fileStore.readFully(filePos, 128); buff = fileStore.readFully(filePos, 128);
maxLength = buff.getInt(); maxLength = buff.getInt();
// read the first bytes again // read the first bytes again
} }
maxLength = (int) Math.min(fileSize - filePos, maxLength);
int length = maxLength;
if (length < 0) {
throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,
"Illegal page length {0} reading at {1}; file size {1} ", length, filePos, fileSize);
}
buff = fileStore.readFully(filePos, length); buff = fileStore.readFully(filePos, length);
Page p = new Page(map, 0); Page p = new Page(map, 0);
p.pos = pos; p.pos = pos;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论