classlib: fix NPE when passing null to Arrays.toString (#667)

This commit is contained in:
Ivan Hetman 2023-02-28 10:46:59 +02:00 committed by GitHub
parent 971fa9a1f3
commit 07d56f1b0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -217,6 +217,9 @@ public class TArrays extends TObject {
}
public static String toString(TObject[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -230,6 +233,9 @@ public class TArrays extends TObject {
}
public static String toString(boolean[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -243,6 +249,9 @@ public class TArrays extends TObject {
}
public static String toString(byte[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -256,6 +265,9 @@ public class TArrays extends TObject {
}
public static String toString(short[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -269,6 +281,9 @@ public class TArrays extends TObject {
}
public static String toString(char[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -282,6 +297,9 @@ public class TArrays extends TObject {
}
public static String toString(int[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -295,6 +313,9 @@ public class TArrays extends TObject {
}
public static String toString(long[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -308,6 +329,9 @@ public class TArrays extends TObject {
}
public static String toString(float[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -321,6 +345,9 @@ public class TArrays extends TObject {
}
public static String toString(double[] a) {
if (a == null) {
return "null";
}
TStringBuilder sb = new TStringBuilder();
sb.append("[");
for (int i = 0; i < a.length; ++i) {
@ -1552,6 +1579,9 @@ public class TArrays extends TObject {
}
public static String deepToString(Object[] a) {
if (a == null) {
return "null";
}
StringBuilder sb = new StringBuilder();
deepToString(a, sb, new TArrayList<>());
return sb.toString();