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

catching NullPointerException is very bad practice

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