The following issues were found
src/test/java/com/alibaba/fastjson/deserializer/issue2358/TestJson.java
3 issues
Line: 62
" \"test2\":\"2\"\n" +
" }]";
List<TestJson2> testJsons = JSONObject.parseArray(str, TestJson2.class);
System.out.println(testJsons);
}
}
Reported by PMD.
Line: 10
/**
* Created by liangchuyi on 2019/4/8.
*/
public class TestJson {
private String test1;
private String test2;
public String getTest1() {
Reported by PMD.
Line: 31
this.test2 = test2;
}
class TestJson2 {
private String test1;
private String test2;
public String getTest1() {
return test1;
Reported by PMD.
src/main/java/com/alibaba/fastjson/util/ThreadLocalCache.java
3 issues
Line: 9
/**
* @deprecated
*/
public class ThreadLocalCache {
public final static int CHARS_CACH_INIT_SIZE = 1024; // 1k, 2^10;
public final static int CHARS_CACH_INIT_SIZE_EXP = 10;
public final static int CHARS_CACH_MAX_SIZE = 1024 * 128; // 128k, 2^17;
public final static int CHARS_CACH_MAX_SIZE_EXP = 17;
Reported by PMD.
Line: 39
return allocate(length);
}
char[] chars = ref.get();
if (chars == null) {
return allocate(length);
}
Reported by PMD.
Line: 94
return allocateBytes(length);
}
byte[] bytes = ref.get();
if (bytes == null) {
return allocateBytes(length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/FastJsonSerializeIterableTest.java
3 issues
Line: 17
@Test
public void testWithIterable() {
class Person {
private String name;
public Person(String s) {
this.name = s;
}
public String getName() {
return name;
Reported by PMD.
Line: 17
@Test
public void testWithIterable() {
class Person {
private String name;
public Person(String s) {
this.name = s;
}
public String getName() {
return name;
Reported by PMD.
Line: 31
@Override
public Iterator<Person> iterator() {
return new Iterator<Person>() {
int cursor = 0;
@Override
public boolean hasNext() {
return cursor < 2;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue1036.java
3 issues
Line: 18
* @see BeanToArrayTest3_private#test_array()
* @see com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer#parseField
* */
public void test_for_issue() throws Exception {
NullPointerException exception = new NullPointerException("test");
Result<String> result = new Result<String>();
result.setException(exception);
String json = JSON.toJSONString(result);
Reported by PMD.
Line: 28
Result<String> a = JSON.parseObject(json, new TypeReference<Result<String>>() {
});
Assert.assertEquals("test", a.getException().getMessage());
}
public static class Result<T> {
private T data;
Reported by PMD.
Line: 31
Assert.assertEquals("test", a.getException().getMessage());
}
public static class Result<T> {
private T data;
private Throwable exception;
public Result() {
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/spring/FastJsonViewResponseBodyAdvice.java
3 issues
Line: 46
MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
FastJsonFilter[] include = annotation.include();
FastJsonFilter[] exclude = annotation.exclude();
PropertyPreFilters filters = new PropertyPreFilters();
for (FastJsonFilter item : include) {
filters.addFilter(item.clazz(),item.props());
}
Reported by PMD.
Line: 47
FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
FastJsonFilter[] include = annotation.include();
FastJsonFilter[] exclude = annotation.exclude();
PropertyPreFilters filters = new PropertyPreFilters();
for (FastJsonFilter item : include) {
filters.addFilter(item.clazz(),item.props());
}
for (FastJsonFilter item : exclude) {
Reported by PMD.
Line: 53
filters.addFilter(item.clazz(),item.props());
}
for (FastJsonFilter item : exclude) {
filters.addFilter(item.clazz()).addExcludes(item.props());
}
container.setFilters(filters);
}
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/Feature.java
3 issues
Line: 170
return (features & feature.mask) != 0;
}
public static int config(int features, Feature feature, boolean state) {
if (state) {
features |= feature.mask;
} else {
features &= ~feature.mask;
}
Reported by PMD.
Line: 170
return (features & feature.mask) != 0;
}
public static int config(int features, Feature feature, boolean state) {
if (state) {
features |= feature.mask;
} else {
features &= ~feature.mask;
}
Reported by PMD.
Line: 180
return features;
}
public static int of(Feature[] features) {
if (features == null) {
return 0;
}
int value = 0;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue126.java
3 issues
Line: 13
JSONObject j = new JSONObject();
j.put("content",
"爸爸去哪儿-第十期-萌娃比赛小猪快跑 爸爸上演\"百变大咖秀\"-【湖南卫视官方版1080P】20131213: http://youtu.be/ajvaXKAduJ4 via @youtube");
System.out.println(j.toJSONString());
}
}
Reported by PMD.
Line: 9
public class Issue126 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject j = new JSONObject();
j.put("content",
"爸爸去哪儿-第十期-萌娃比赛小猪快跑 爸爸上演\"百变大咖秀\"-【湖南卫视官方版1080P】20131213: http://youtu.be/ajvaXKAduJ4 via @youtube");
System.out.println(j.toJSONString());
}
Reported by PMD.
Line: 9
public class Issue126 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject j = new JSONObject();
j.put("content",
"爸爸去哪儿-第十期-萌娃比赛小猪快跑 爸爸上演\"百变大咖秀\"-【湖南卫视官方版1080P】20131213: http://youtu.be/ajvaXKAduJ4 via @youtube");
System.out.println(j.toJSONString());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue1296.java
3 issues
Line: 11
* Created by wenshao on 02/07/2017.
*/
public class Issue1296 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSON.parseObject("1");
} catch (JSONException e) {
error = e;
Reported by PMD.
Line: 18
} catch (JSONException e) {
error = e;
}
assertNotNull(error);
}
}
Reported by PMD.
Line: 12
*/
public class Issue1296 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSON.parseObject("1");
} catch (JSONException e) {
error = e;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue157.java
3 issues
Line: 14
JSONObject json = new JSONObject();
json.put("介绍", m);
String content = json.toJSONString();
System.out.println(content);
}
}
Reported by PMD.
Line: 9
public class Issue157 extends TestCase {
public void test_for_issue() throws Exception {
String m = "2、95开头靓号,呼出显号,对方可以打回,即使不在线亦可设置呼转手机,不错过任何重要电话,不暴露真实身份。\r\n3、应用内完全免费发送文字消息、语音对讲。\r\n4、建议WIFI 或 3G 环境下使用以获得最佳通话体验";
JSONObject json = new JSONObject();
json.put("介绍", m);
String content = json.toJSONString();
System.out.println(content);
Reported by PMD.
Line: 9
public class Issue157 extends TestCase {
public void test_for_issue() throws Exception {
String m = "2、95开头靓号,呼出显号,对方可以打回,即使不在线亦可设置呼转手机,不错过任何重要电话,不暴露真实身份。\r\n3、应用内完全免费发送文字消息、语音对讲。\r\n4、建议WIFI 或 3G 环境下使用以获得最佳通话体验";
JSONObject json = new JSONObject();
json.put("介绍", m);
String content = json.toJSONString();
System.out.println(content);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue171.java
3 issues
Line: 16
Map m = new HashMap();
m.put("a", "\u000B");
String json = JSON.toJSONString(m);
System.out.println(json);
JSON.parse(json);
}
}
Reported by PMD.
Line: 12
public class Issue171 extends TestCase {
public void test_for_issue() throws Exception {
Map m = new HashMap();
m.put("a", "\u000B");
String json = JSON.toJSONString(m);
System.out.println(json);
JSON.parse(json);
Reported by PMD.
Line: 12
public class Issue171 extends TestCase {
public void test_for_issue() throws Exception {
Map m = new HashMap();
m.put("a", "\u000B");
String json = JSON.toJSONString(m);
System.out.println(json);
JSON.parse(json);
Reported by PMD.