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