This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit 5b020dba27e7cf6a62ecfee49d997fd0902251a7 Author: XenoAmess <xenoam...@gmail.com> AuthorDate: Sun Jun 7 18:28:03 2020 +0800 MATH-1543: Avoid exception swallowing. Closes #149. --- .../commons/math4/linear/ArrayFieldVector.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java index 4b8664c..00e58b7 100644 --- a/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java +++ b/src/main/java/org/apache/commons/math4/linear/ArrayFieldVector.java @@ -1050,23 +1050,21 @@ public class ArrayFieldVector<T extends FieldElement<T>> implements FieldVector< return false; } - try { - @SuppressWarnings("unchecked") // May fail, but we ignore ClassCastException - FieldVector<T> rhs = (FieldVector<T>) other; - if (data.length != rhs.getDimension()) { - return false; - } + if (!(other instanceof FieldVector)) { + return false; + } - for (int i = 0; i < data.length; ++i) { - if (!data[i].equals(rhs.getEntry(i))) { - return false; - } - } - return true; - } catch (ClassCastException ex) { - // ignore exception + FieldVector rhs = (FieldVector) other; + if (data.length != rhs.getDimension()) { return false; } + + for (int i = 0; i < data.length; ++i) { + if (!data[i].equals(rhs.getEntry(i))) { + return false; + } + } + return true; } /**