You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/05/28 12:42:37 UTC

[lang] Fix compiler type warning

Repository: commons-lang
Updated Branches:
  refs/heads/master 9bc992b13 -> 17e654881


Fix compiler type warning

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/17e65488
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/17e65488
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/17e65488

Branch: refs/heads/master
Commit: 17e65488113a2dbe9894f824f4321a06ee009e02
Parents: 9bc992b
Author: Sebb <se...@apache.org>
Authored: Sat May 28 13:42:32 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Sat May 28 13:42:32 2016 +0100

----------------------------------------------------------------------
 .../commons/lang3/StringUtilsStartsEndsWithTest.java     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/17e65488/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java
index a351a2f..fef99bc 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java
@@ -179,7 +179,16 @@ public class StringUtilsStartsEndsWithTest {
         assertFalse(StringUtils.endsWithAny("abcXYZ", "def", "xyz"));
         assertTrue(StringUtils.endsWithAny("abcXYZ", "def", "YZ"));
 
-        assertFalse(StringUtils.endsWithAny("abcXYZ", null));
+        /*
+         * Type null of the last argument to method endsWithAny(CharSequence, CharSequence...)
+         * doesn't exactly match the vararg parameter type. 
+         * Cast to CharSequence[] to confirm the non-varargs invocation,
+         * or pass individual arguments of type CharSequence for a varargs invocation.
+         *
+         * assertFalse(StringUtils.endsWithAny("abcXYZ", null)); // replace with specific types to avoid warning
+         */
+        assertFalse(StringUtils.endsWithAny("abcXYZ", (CharSequence) null));
+        assertFalse(StringUtils.endsWithAny("abcXYZ", (CharSequence[]) null));
         assertTrue(StringUtils.endsWithAny("abcXYZ", ""));
 
         assertTrue("StringUtils.endsWithAny(abcxyz, StringBuilder(abc), StringBuffer(xyz))", StringUtils.endsWithAny("abcxyz", new StringBuilder("abc"), new StringBuffer("xyz")));