[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-09-03 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r701554900



##
File path: src/test/java/org/apache/commons/lang3/StringUtilsTest.java
##
@@ -1355,15 +1372,6 @@ public void testJoin_Objectarray() {
 assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST));
 }
 
-@Disabled

Review comment:
   This is exactly the test that exposes this bug: ```testLang1593```. 
   Please find the same assertion here ```testJoin_ArrayOfInt``` in 
```StringUtilsTest```
   
   ``` assertEquals("1,2", StringUtils.join(INT_PRIM_LIST, SEPARATOR));```
   
   When it comes to coverage, it looks like ```join``` methods have 100% 
coverage. 
   
   ![Screen Shot 2021-09-03 at 8 21 40 
PM](https://user-images.githubusercontent.com/2518652/132050465-f7a8edb4-e258-4edd-b779-a488a40f0aa3.png)
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-09-02 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r701557984



##
File path: src/test/java/org/apache/commons/lang3/StringUtilsTest.java
##
@@ -1226,6 +1241,8 @@ public void testJoin_ArrayOfShorts() {
 assertNull(StringUtils.join((short[]) null, SEPARATOR_CHAR, 0, 1));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 0, 0));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 1, 0));
+assertEquals("1,2", StringUtils.join(SHORT_PRIM_LIST, SEPARATOR));

Review comment:
   The joining part is done via ```java.util.StringJoiner``` with accepts 
only```CharSequence``` in constructor, so it's made to use more than one 
character as separator by default. Don't you think that testing that would be 
redundant?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-09-02 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r701554900



##
File path: src/test/java/org/apache/commons/lang3/StringUtilsTest.java
##
@@ -1355,15 +1372,6 @@ public void testJoin_Objectarray() {
 assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST));
 }
 
-@Disabled

Review comment:
   This is exactly the test that exposes this bug: ```testLang1593```. 
   Please find the same assertion here ```testJoin_ArrayOfInt``` in 
```StringUtilsTest```
   
   ``` assertEquals("1,2", StringUtils.join(INT_PRIM_LIST, SEPARATOR));```
   
   When it comes to coverage, it looks like ```join``` methods have 100% 
coverage. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-09-02 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r701551517



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -4858,6 +5082,209 @@ public static String join(final short[] array, final 
char delimiter, final int s
 return join(elements, null);
 }
 
+/**
+ * Joins the elements of the provided array into a single String
+ * containing the provided list of elements.
+ *
+ * No delimiter is added before or after the list. Null objects or 
empty strings within the array are represented
+ * by empty strings.
+ *
+ * 
+ * StringUtils.join(null)= null
+ * StringUtils.join([])  = ""
+ * StringUtils.join([null])  = ""
+ * StringUtils.join([1, 2, 3], ";")  = "1;2;3"
+ * StringUtils.join([1, 2, 3], null) = "123"
+ * 
+ *
+ * @param elements
+ *the values to join together, may be null
+ * @param separator
+ *the separator String to use
+ * @return the joined String, {@code null} if null array input
+ * @since 3.13.0
+ */
+public static String join(final byte[] elements, final String separator) {
+return elements == null ? null : join(elements, separator, 0, 
elements.length);
+}
+
+/**
+ * Joins the elements of the provided array into a single String
+ * containing the provided list of elements.
+ *
+ * No delimiter is added before or after the list. Null objects or 
empty strings within the array are represented
+ * by empty strings.
+ *
+ * 
+ * StringUtils.join(null) = null
+ * StringUtils.join([])   = ""
+ * StringUtils.join([null])   = ""
+ * StringUtils.join([false,true,false], ";")  = "false;true;false"
+ * StringUtils.join([false,true,false], null) = "falsetruefalse"
+ * 
+ *
+ * @param elements
+ *the values to join together, may be null
+ * @param separator
+ *the separator String to use
+ * @return the joined String, {@code null} if null array input
+ * @since 3.13.0
+ */
+public static String join(final boolean[] elements, final String 
separator) {
+return elements == null ? null : join(elements, separator, 0, 
elements.length);
+}
+
+/**
+ * Joins the elements of the provided array into a single String
+ * containing the provided list of elements.
+ *
+ * No delimiter is added before or after the list. Null objects or 
empty strings within the array are represented
+ * by empty strings.
+ *
+ * 
+ * StringUtils.join(null)   = null
+ * StringUtils.join([]) = ""
+ * StringUtils.join([null]) = ""
+ * StringUtils.join(['a', 'b', 'c'], ";")   = "a;b;c"
+ * StringUtils.join(['a', 'b', 'c'], null)  = "abc"
+ * 
+ *
+ * @param elements
+ *the values to join together, may be null
+ * @param separator
+ *the separator String to use
+ * @return the joined String, {@code null} if null array input
+ * @since 3.13.0
+ */
+public static String join(final char[] elements, final String separator) {
+return elements == null ? null : join(elements, separator, 0, 
elements.length);

Review comment:
   1. The method is public - so users may pass  ```null```  as 
```elements``` which will cause ```NPE``` in the same line ```elements.length```
   ```
   assertNull(StringUtils.join((char[]) null, "-")); // throws NPE if null 
check is removed
   ```
   2. This case was not tested, so I added additional assertions in tests to 
cover it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-09-01 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r699853027



##
File path: src/test/java/org/apache/commons/lang3/StringUtilsTest.java
##
@@ -1226,6 +1241,8 @@ public void testJoin_ArrayOfShorts() {
 assertNull(StringUtils.join((short[]) null, SEPARATOR_CHAR, 0, 1));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 0, 0));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 1, 0));
+assertEquals("1,2", StringUtils.join(SHORT_PRIM_LIST, SEPARATOR));

Review comment:
   Sorry for the late reply, I was on vac. 
   I will take a look on your comments and try to apply changes later this 
week. 
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-31 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r699853027



##
File path: src/test/java/org/apache/commons/lang3/StringUtilsTest.java
##
@@ -1226,6 +1241,8 @@ public void testJoin_ArrayOfShorts() {
 assertNull(StringUtils.join((short[]) null, SEPARATOR_CHAR, 0, 1));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 0, 0));
 assertEquals(StringUtils.EMPTY, StringUtils.join(SHORT_PRIM_LIST, 
SEPARATOR_CHAR, 1, 0));
+assertEquals("1,2", StringUtils.join(SHORT_PRIM_LIST, SEPARATOR));

Review comment:
   Sorry for the late reply, I was on vac. 
   I will take a look on your comments and try to apply changes later this 
week. 
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-22 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r693455055



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -3922,6 +3922,37 @@ public static String join(final boolean[] array, final 
char delimiter) {
  * @since 3.12.0
  */
 public static String join(final boolean[] array, final char delimiter, 
final int startIndex, final int endIndex) {
+return join(array, String.valueOf(delimiter), startIndex, endIndex);
+}
+
+/**
+ * Joins the elements of the provided array into a single String 
containing the provided list of elements.

Review comment:
   Thanks for pointing this out, I didn't know about such rule. 
   Unnecessary paragraph tags removed. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-22 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r693455055



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -3922,6 +3922,37 @@ public static String join(final boolean[] array, final 
char delimiter) {
  * @since 3.12.0
  */
 public static String join(final boolean[] array, final char delimiter, 
final int startIndex, final int endIndex) {
+return join(array, String.valueOf(delimiter), startIndex, endIndex);
+}
+
+/**
+ * Joins the elements of the provided array into a single String 
containing the provided list of elements.

Review comment:
   Thanks for pointing this out, I didn't know about such rule. 
   Additional paragraph tags removed. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-05 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r683724884



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -4858,6 +5127,38 @@ public static String join(final short[] array, final 
char delimiter, final int s
 return join(elements, null);
 }
 
+public static String join(byte[] elements, String separator) {

Review comment:
   Added. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-05 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r683719682



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -4307,13 +4481,48 @@ public static String join(final int[] array, final char 
separator) {
  * @since 3.2
  */
 public static String join(final int[] array, final char delimiter, final 
int startIndex, final int endIndex) {
+return join(array, String.valueOf(delimiter), startIndex, endIndex);
+}
+
+/**
+ * 
+ * Joins the elements of the provided array into a single String 
containing the provided list of elements.
+ * 
+ *
+ * 
+ * No delimiter is added before or after the list. Null objects or empty 
strings within the array are represented
+ * by empty strings.
+ * 
+ *
+ * 
+ * StringUtils.join(null, *)   = null
+ * StringUtils.join([], *) = ""
+ * StringUtils.join([null], *) = ""
+ * StringUtils.join([1, 2, 3], ';')  = "1;2;3"
+ * StringUtils.join([1, 2, 3], null) = "123"
+ * 
+ *
+ * @param array
+ *the array of values to join together, may be null
+ * @param delimiter
+ *the separator String to use
+ * @param startIndex
+ *the first index to start joining from. It is an error to 
pass in a start index past the end of the
+ *array
+ * @param endIndex
+ *the index to stop joining from (exclusive). It is an error 
to pass in an end index past the end of
+ *the array
+ * @return the joined String, {@code null} if null array input
+ * @since 3.13.0
+ */
+public static String join(final int[] array, final String delimiter, final 
int startIndex, final int endIndex) {
 if (array == null) {
 return null;
 }
 if (endIndex - startIndex <= 0) {
 return EMPTY;
 }
-final StringJoiner joiner = newStringJoiner(delimiter);
+final StringJoiner joiner = new 
StringJoiner(toStringOrEmpty(delimiter));

Review comment:
   Valid point. I brought it back. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-05 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r683719485



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -4818,13 +5052,48 @@ public static String join(final short[] array, final 
char delimiter) {
  * @since 3.2
  */
 public static String join(final short[] array, final char delimiter, final 
int startIndex, final int endIndex) {
+return join(array, String.valueOf(delimiter), startIndex, endIndex);
+}
+
+/**
+ * 

Review comment:
   I've followed convention from other Javadoc in the file. Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [commons-lang] HubertWo commented on a change in pull request #784: [LANG-1593] Common behavior for StringUtils join APIs when called with char or String delimiter

2021-08-05 Thread GitBox


HubertWo commented on a change in pull request #784:
URL: https://github.com/apache/commons-lang/pull/784#discussion_r683718647



##
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##
@@ -4858,6 +5127,38 @@ public static String join(final short[] array, final 
char delimiter, final int s
 return join(elements, null);
 }
 
+public static String join(byte[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(boolean[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(char[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(double[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(float[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(int[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(long[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}
+
+public static String join(short[] elements, String separator) {
+return (elements == null) ? null : join(elements, separator, 0, 
elements.length);
+}

Review comment:
   Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org