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 2022/11/25 14:56:30 UTC

[commons-validator] branch master updated: Use toArray() with 0 size array pattern

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-validator.git


The following commit(s) were added to refs/heads/master by this push:
     new 624240bf Use toArray() with 0 size array pattern
624240bf is described below

commit 624240bf14c8c0b7f2e781afbb47839c010bb6c0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 25 09:56:26 2022 -0500

    Use toArray() with 0 size array pattern
---
 .../org/apache/commons/validator/routines/InetAddressValidator.java     | 2 +-
 .../commons/validator/routines/checkdigit/AbstractCheckDigitTest.java   | 2 +-
 .../commons/validator/routines/checkdigit/IBANCheckDigitTest.java       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
index 013bb529..bb98beb8 100644
--- a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java
@@ -170,7 +170,7 @@ public class InetAddressValidator implements Serializable {
             } else if (inet6Address.startsWith("::") && !octetList.isEmpty()) {
                 octetList.remove(0);
             }
-            octets = octetList.toArray(new String[octetList.size()]);
+            octets = octetList.toArray(new String[0]);
         }
         if (octets.length > IPV6_MAX_HEX_GROUPS) {
             return false;
diff --git a/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java b/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
index 195fa4e9..1b096bb0 100644
--- a/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/checkdigit/AbstractCheckDigitTest.java
@@ -300,7 +300,7 @@ public abstract class AbstractCheckDigitTest extends TestCase {
             }
         }
 
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java b/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java
index ec0de49e..74f24bf5 100644
--- a/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java
+++ b/src/test/java/org/apache/commons/validator/routines/checkdigit/IBANCheckDigitTest.java
@@ -200,7 +200,7 @@ public class IBANCheckDigitTest extends AbstractCheckDigitTest {
             }
         }
 
-        return list.toArray(new String[list.size()]);
+        return list.toArray(new String[0]);
     }
 
     /**