This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit 01cb55acd3068e0518b88730c73f0081a557efdd Author: Alex Herbert <[email protected]> AuthorDate: Wed Apr 8 22:13:15 2020 +0100 Fraction constructor cannot throw an arithmetic exception The greatest common divisor is never called with the 3 cases where ArithmeticUtils.gcd can throw an exception. --- .../main/java/org/apache/commons/numbers/fraction/Fraction.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java index b6dcef6..7fc5c7e 100644 --- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java +++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java @@ -61,8 +61,7 @@ public final class Fraction * * @param num Numerator. * @param den Denominator. - * @throws ArithmeticException if the denominator is {@code zero} - * or if integer overflow occurs. + * @throws ArithmeticException if the denominator is {@code zero}. */ private Fraction(int num, int den) { if (den == 0) { @@ -88,6 +87,7 @@ public final class Fraction q = den; } + // Will not throw final int d = ArithmeticUtils.gcd(p, q); if (d > 1) { p /= d; @@ -297,8 +297,7 @@ public final class Fraction * * @param num Numerator. * @param den Denominator. - * @throws ArithmeticException if the denominator is {@code zero} - * or if integer overflow occurs. + * @throws ArithmeticException if the denominator is {@code zero}. * @return a new instance. */ public static Fraction of(final int num, final int den) {
