You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/01/24 14:05:36 UTC
[commons-lang] branch master updated: Reduce magic number usage.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new bb52448 Reduce magic number usage.
bb52448 is described below
commit bb5244814ca59d1ce896e68fdbe0dc8928b32532
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jan 24 09:05:31 2020 -0500
Reduce magic number usage.
---
.../org/apache/commons/lang3/exception/ExceptionUtils.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
index 152c809..3a1d699 100644
--- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
+++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java
@@ -39,6 +39,8 @@ import org.apache.commons.lang3.Validate;
*/
public class ExceptionUtils {
+ private static final int NOT_FOUND = -1;
+
/**
* <p>The names of methods commonly used to access a wrapped exception.</p>
*/
@@ -299,7 +301,7 @@ public class ExceptionUtils {
final String token = frames.nextToken();
// Determine if the line starts with <whitespace>at
final int at = token.indexOf("at");
- if (at != -1 && token.substring(0, at).trim().isEmpty()) {
+ if (at != NOT_FOUND && token.substring(0, at).trim().isEmpty()) {
traceStarted = true;
list.add(token);
} else if (traceStarted) {
@@ -475,14 +477,14 @@ public class ExceptionUtils {
*/
private static int indexOf(final Throwable throwable, final Class<?> type, int fromIndex, final boolean subclass) {
if (throwable == null || type == null) {
- return -1;
+ return NOT_FOUND;
}
if (fromIndex < 0) {
fromIndex = 0;
}
final Throwable[] throwables = getThrowables(throwable);
if (fromIndex >= throwables.length) {
- return -1;
+ return NOT_FOUND;
}
if (subclass) {
for (int i = fromIndex; i < throwables.length; i++) {
@@ -497,7 +499,7 @@ public class ExceptionUtils {
}
}
}
- return -1;
+ return NOT_FOUND;
}
/**