提交 b45115c6 authored 作者: Noel Grandin's avatar Noel Grandin

catching NullPointerException is very bad practice

and makes finding real NPE problems super hard
上级 c3b962ad
......@@ -50,29 +50,33 @@ public class RangeIndex extends BaseIndex {
long min = rangeTable.getMin(session);
long max = rangeTable.getMax(session);
long step = rangeTable.getStep(session);
try {
long v = first.getValue(0).getLong();
if (step > 0) {
if (v > min) {
min += (v - min + step - 1) / step * step;
if (first != null) {
try {
long v = first.getValue(0).getLong();
if (step > 0) {
if (v > min) {
min += (v - min + step - 1) / step * step;
}
} else if (v > max) {
max = v;
}
} else if (v > max) {
max = v;
} catch (DbException e) {
// error when converting the value - ignore
}
} catch (Exception e) {
// error when converting the value - ignore
}
try {
long v = last.getValue(0).getLong();
if (step > 0) {
if (v < max) {
max = v;
if (last != null) {
try {
long v = last.getValue(0).getLong();
if (step > 0) {
if (v < max) {
max = v;
}
} else if (v < min) {
min -= (min - v - step - 1) / step * step;
}
} else if (v < min) {
min -= (min - v - step - 1) / step * step;
} catch (DbException e) {
// error when converting the value - ignore
}
} catch (Exception e) {
// error when converting the value - ignore
}
return new RangeCursor(session, min, max, step);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论