Explorar o código

修复Byte[]类型参数死循环的问题

周艺峰 %!s(int64=5) %!d(string=hai) anos
pai
achega
a2dede8448

+ 11 - 1
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/text/Convert.java

@@ -797,7 +797,17 @@ public class Convert
797 797
         }
798 798
         else if (obj instanceof byte[] || obj instanceof Byte[])
799 799
         {
800
-            return str((Byte[]) obj, charset);
800
+            if (obj instanceof byte[]){
801
+                return str((byte[]) obj, charset);
802
+            } else {
803
+                Byte[] bytes = (Byte[])obj;
804
+                int length = bytes.length;
805
+                byte[] dest = new byte[length];
806
+                for (int i = 0; i < length; i++) {
807
+                    dest[i] = bytes[i];
808
+                }
809
+            return str (dest,charset);
810
+            }
801 811
         }
802 812
         else if (obj instanceof ByteBuffer)
803 813
         {