This commit is contained in:
Looly
2021-02-03 13:33:31 +08:00
parent 1a7812a281
commit 0056560a93
5 changed files with 42 additions and 21 deletions

View File

@@ -11,6 +11,7 @@ import cn.hutool.json.test.bean.UserC;
import org.junit.Assert;
import org.junit.Test;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -179,4 +180,12 @@ public class JSONUtilTest {
" \"test\": \"\\\\地库地库\",\n" +
"}");
}
@Test
public void sqlExceptionTest(){
//https://github.com/looly/hutool/issues/1401
// SQLException实现了Iterable接口默认是遍历之会栈溢出修正后只返回string
final JSONObject set = JSONUtil.createObj().set("test", new SQLException("test"));
Assert.assertEquals("{\"test\":\"java.sql.SQLException: test\"}", set.toString());
}
}