Skip to content

Commit

Permalink
[FLINK-17175][core] StringUtils.arrayToString() should consider Objec…
Browse files Browse the repository at this point in the history
…t[] lastly
  • Loading branch information
bowenli86 committed Apr 24, 2020
1 parent c4b44e9 commit 6128bd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ public static String arrayToString(Object array) {
if (array instanceof long[]) {
return Arrays.toString((long[]) array);
}
if (array instanceof Object[]) {
return Arrays.toString((Object[]) array);
}
// for array of byte array
if (array instanceof byte[][]) {
byte[][] b = (byte[][]) array;
Expand Down Expand Up @@ -171,6 +168,9 @@ public static String arrayToString(Object array) {
if (array instanceof short[]) {
return Arrays.toString((short[]) array);
}
if (array instanceof Object[]) {
return Arrays.toString((Object[]) array);
}

if (array.getClass().isArray()) {
return "<unknown array type>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ public void testControlCharacters() {
assertEquals("\\b \\t \\n \\f \\r default", controlString);
}

@Test
public void testArrayOfBytesArray() {
byte[][] expectedArray = new byte[][]{
{1, -97, 49, 74 },
{2, -92, 48, 73 }
};

String controlString = StringUtils.arrayToString(expectedArray);
assertEquals("[[1, -97, 49, 74], [2, -92, 48, 73]]", controlString);
}

@Test
public void testArrayToString() {
double[] array = {1.0};
Expand Down

0 comments on commit 6128bd1

Please sign in to comment.