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/06/13 18:05:43 UTC
[commons-lang] branch master updated: Use
ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
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 496eb10 Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
496eb10 is described below
commit 496eb10372c0161eac4729e758d789357adfcc0f
Author: Edgar Asatryan <17...@users.noreply.github.com>
AuthorDate: Sat Jun 13 22:05:33 2020 +0400
Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
---
src/main/java/org/apache/commons/lang3/ArrayUtils.java | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index dd9b5ca..ffd250d 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -1679,13 +1679,7 @@ public class ArrayUtils {
* @since 3.11
*/
public static <T> T get(final T[] array, final int index, final T defaultValue) {
- if (array == null) {
- return defaultValue;
- }
- if (index >= 0 && index < array.length) {
- return array[index];
- }
- return defaultValue;
+ return isArrayIndexValid(array, index) ? array[index] : defaultValue;
}
//-----------------------------------------------------------------------