You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/09/29 14:07:21 UTC
[commons-numbers] 01/06: Exceptions must be "Serializable".
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-numbers.git
commit eefcd5f64158e7da2764a63be5b9fd7734146af8
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sun Sep 29 15:38:10 2019 +0200
Exceptions must be "Serializable".
Reported by "SonarQube".
---
.../numbers/combinatorics/CombinatoricsException.java | 19 +++++--------------
.../apache/commons/numbers/core/ArithmeticUtils.java | 11 +----------
.../commons/numbers/fraction/FractionException.java | 14 +-------------
.../apache/commons/numbers/gamma/GammaException.java | 11 +----------
.../commons/numbers/rootfinder/SolverException.java | 12 +-----------
5 files changed, 9 insertions(+), 58 deletions(-)
diff --git a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/CombinatoricsException.java b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/CombinatoricsException.java
index 6514293..2543254 100644
--- a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/CombinatoricsException.java
+++ b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/CombinatoricsException.java
@@ -32,24 +32,15 @@ class CombinatoricsException extends IllegalArgumentException {
/** Serializable version identifier. */
private static final long serialVersionUID = 20170515L;
- /** Arguments for formatting the message. */
- protected Object[] formatArguments;
-
/**
* Create an exception where the message is constructed by applying
* the {@code format()} method from {@code java.text.MessageFormat}.
*
- * @param message the exception message with replaceable parameters
- * @param formatArguments the arguments for formatting the message
+ * @param message Exception message with replaceable parameters.
+ * @param formatArguments 1rguments for formatting the message.
*/
- CombinatoricsException(String message, Object... formatArguments) {
- super(message);
- this.formatArguments = formatArguments;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getMessage() {
- return MessageFormat.format(super.getMessage(), formatArguments);
+ CombinatoricsException(String message,
+ Object... formatArguments) {
+ super(MessageFormat.format(message, formatArguments));
}
}
diff --git a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
index b6bbc45..af72311 100644
--- a/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
+++ b/commons-numbers-core/src/main/java/org/apache/commons/numbers/core/ArithmeticUtils.java
@@ -538,8 +538,6 @@ public final class ArithmeticUtils {
private static class NumbersArithmeticException extends ArithmeticException {
/** Serializable version Id. */
private static final long serialVersionUID = 20180130L;
- /** Argument to construct a message. */
- private final Object[] formatArguments;
/**
* Default constructor.
@@ -556,14 +554,7 @@ public final class ArithmeticUtils {
* @param args Arguments.
*/
NumbersArithmeticException(String message, Object ... args) {
- super(message);
- this.formatArguments = args;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getMessage() {
- return MessageFormat.format(super.getMessage(), formatArguments);
+ super(MessageFormat.format(message, args));
}
}
}
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
index 1831477..4ce0a69 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionException.java
@@ -35,9 +35,6 @@ class FractionException extends ArithmeticException {
/** Serializable version identifier. */
private static final long serialVersionUID = 201701191744L;
- /** Arguments for formatting the message. */
- protected Object[] formatArguments;
-
/**
* Create an exception where the message is constructed by applying
* the {@code format()} method from {@code java.text.MessageFormat}.
@@ -46,15 +43,6 @@ class FractionException extends ArithmeticException {
* @param formatArguments the arguments for formatting the message
*/
FractionException(String message, Object... formatArguments) {
- super(message);
- this.formatArguments = formatArguments;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getMessage() {
- return MessageFormat.format(super.getMessage(), formatArguments);
+ super(MessageFormat.format(message, formatArguments));
}
-
-
}
diff --git a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/GammaException.java b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/GammaException.java
index 7122f2e..13e9276 100644
--- a/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/GammaException.java
+++ b/commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma/GammaException.java
@@ -30,9 +30,6 @@ class GammaException extends IllegalArgumentException {
/** Serializable version identifier. */
private static final long serialVersionUID = 20170505L;
- /** Arguments for formatting the message. */
- protected Object[] formatArguments;
-
/**
* Create an exception where the message is constructed by applying
* the {@code format()} method from {@code java.text.MessageFormat}.
@@ -41,12 +38,6 @@ class GammaException extends IllegalArgumentException {
* @param formatArguments the arguments for formatting the message
*/
GammaException(String message, Object... formatArguments) {
- super(message);
- this.formatArguments = formatArguments;
- }
-
- @Override
- public String getMessage() {
- return MessageFormat.format(super.getMessage(), formatArguments);
+ super(MessageFormat.format(message, formatArguments));
}
}
diff --git a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/SolverException.java b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/SolverException.java
index c35f2fe..32412f2 100644
--- a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/SolverException.java
+++ b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/SolverException.java
@@ -32,9 +32,6 @@ class SolverException extends IllegalArgumentException {
/** Serializable version identifier. */
private static final long serialVersionUID = 20190602L;
- /** Arguments for formatting the message. */
- private final Object[] formatArguments;
-
/**
* Create an exception where the message is constructed by applying
* the {@code format()} method from {@code java.text.MessageFormat}.
@@ -43,13 +40,6 @@ class SolverException extends IllegalArgumentException {
* @param formatArguments the arguments for formatting the message
*/
SolverException(String message, Object... formatArguments) {
- super(message);
- this.formatArguments = formatArguments;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getMessage() {
- return MessageFormat.format(super.getMessage(), formatArguments);
+ super(MessageFormat.format(message, formatArguments));
}
}