The following issues were found
src/test/java/com/alibaba/json/bvt/URIFieldTest.java
4 issues
Line: 14
public class URIFieldTest extends TestCase {
public void test_codec() throws Exception {
User user = new User();
user.setValue(URI.create("http://www.alibaba.com/abc"));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 27
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 37
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public static class User {
private URI value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_ruiqi.java
4 issues
Line: 18
map.put("a", Enum.ENUM1);
map.put("b", Enum.ENUM1);
System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));
System.out.println(JSON.toJSONString(map));
}
Reported by PMD.
Line: 20
System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));
System.out.println(JSON.toJSONString(map));
}
public static enum Enum {
Reported by PMD.
Line: 13
public class Bug_for_ruiqi extends TestCase {
public void test_0() throws Exception {
Map<String, Enum> map = new HashMap<String, Enum>();
map.put("a", Enum.ENUM1);
map.put("b", Enum.ENUM1);
System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));
Reported by PMD.
Line: 13
public class Bug_for_ruiqi extends TestCase {
public void test_0() throws Exception {
Map<String, Enum> map = new HashMap<String, Enum>();
map.put("a", Enum.ENUM1);
map.put("b", Enum.ENUM1);
System.out.println(JSON.toJSONString(map, SerializerFeature.WriteEnumUsingToString));
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_937.java
4 issues
Line: 39
}
public Out(T t) {
setOutPara(t);
}
}
public static class Info {
private String name;
Reported by PMD.
Line: 13
*/
public class Bug_for_issue_937 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{outPara:{name:\"user\"}}";
Out<Info> out = returnOut(json, Info.class);
Assert.assertEquals("user", out.getOutPara().getName());
}
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
String json = "{outPara:{name:\"user\"}}";
Out<Info> out = returnOut(json, Info.class);
Assert.assertEquals("user", out.getOutPara().getName());
}
public static <T> Out<T> returnOut(String jsonStr, Class<T> c2) {
return JSON.parseObject(jsonStr, new TypeReference<Out<T>>(c2) {
});
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
String json = "{outPara:{name:\"user\"}}";
Out<Info> out = returnOut(json, Info.class);
Assert.assertEquals("user", out.getOutPara().getName());
}
public static <T> Out<T> returnOut(String jsonStr, Class<T> c2) {
return JSON.parseObject(jsonStr, new TypeReference<Out<T>>(c2) {
});
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_qqdwll2012.java
4 issues
Line: 16
vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
System.out.println(text);
}
public static class VO {
private String value;
Reported by PMD.
Line: 11
public class Bug_for_qqdwll2012 extends TestCase {
public void test_for_x() throws Exception {
VO vo = new VO();
vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
System.out.println(text);
Reported by PMD.
Line: 11
public class Bug_for_qqdwll2012 extends TestCase {
public void test_for_x() throws Exception {
VO vo = new VO();
vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
System.out.println(text);
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
public class Bug_for_qqdwll2012 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/bug_for_pengsong0302.java
4 issues
Line: 11
public class bug_for_pengsong0302 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("\"a\\u2028b\"", JSON.toJSONString("a\u2028b"));
}
public void test_1() throws Exception {
Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));
Reported by PMD.
Line: 15
Assert.assertEquals("\"a\\u2028b\"", JSON.toJSONString("a\u2028b"));
}
public void test_1() throws Exception {
Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));
}
public void test_2029() throws Exception {
Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));
Reported by PMD.
Line: 19
Assert.assertEquals("{\"value\":\"a\\u2028b\"}", JSON.toJSONString(new A("a\u2028b")));
}
public void test_2029() throws Exception {
Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));
}
public void test_2029_1() throws Exception {
Assert.assertEquals("{\"value\":\"a\\u2029b\"}", JSON.toJSONString(new A("a\u2029b")));
Reported by PMD.
Line: 23
Assert.assertEquals("\"a\\u2029b\"", JSON.toJSONString("a\u2029b"));
}
public void test_2029_1() throws Exception {
Assert.assertEquals("{\"value\":\"a\\u2029b\"}", JSON.toJSONString(new A("a\u2029b")));
}
public static class A {
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/ParseContext.java
4 issues
Line: 7
public class ParseContext {
public Object object;
public final ParseContext parent;
public final Object fieldName;
public final int level;
public Type type;
private transient String path;
Reported by PMD.
Line: 8
public class ParseContext {
public Object object;
public final ParseContext parent;
public final Object fieldName;
public final int level;
public Type type;
private transient String path;
Reported by PMD.
Line: 9
public Object object;
public final ParseContext parent;
public final Object fieldName;
public final int level;
public Type type;
private transient String path;
public ParseContext(ParseContext parent, Object object, Object fieldName){
Reported by PMD.
Line: 10
public Object object;
public final ParseContext parent;
public final Object fieldName;
public final int level;
public Type type;
private transient String path;
public ParseContext(ParseContext parent, Object object, Object fieldName){
this.parent = parent;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue176.java
4 issues
Line: 12
public class Issue176 extends TestCase {
public void test_for_parent() throws Exception {
String text = "{\"content\":\"result\"}";
ParentClass parentClass = JSON.parseObject(text, ParentClass.class);
Assert.assertEquals(parentClass.getTest(), "result");
Reported by PMD.
Line: 17
ParentClass parentClass = JSON.parseObject(text, ParentClass.class);
Assert.assertEquals(parentClass.getTest(), "result");
String text2 = JSON.toJSONString(parentClass);
Assert.assertEquals(text, text2);
}
Reported by PMD.
Line: 23
Assert.assertEquals(text, text2);
}
public void test_for_sub() throws Exception {
String text = "{\"content\":\"result\"}";
SubClass parentClass = JSON.parseObject(text, SubClass.class);
Assert.assertEquals(parentClass.getTest(), "result");
Reported by PMD.
Line: 28
SubClass parentClass = JSON.parseObject(text, SubClass.class);
Assert.assertEquals(parentClass.getTest(), "result");
String text2 = JSON.toJSONString(parentClass);
Assert.assertEquals(text, text2);
}
public static class ParentClass {
Reported by PMD.
src/main/java/com/alibaba/fastjson/JSONPObject.java
4 issues
Line: 51
SerializeWriter writer = serializer.out;
if ((features & SerializerFeature.BrowserSecure.mask) != 0
|| (writer.isEnabled(SerializerFeature.BrowserSecure.mask)))
{
writer.write(SECURITY_PREFIX);
}
writer.write(function);
Reported by PMD.
Line: 56
writer.write(SECURITY_PREFIX);
}
writer.write(function);
writer.write('(');
for (int i = 0; i < parameters.size(); ++i) {
if (i != 0) {
writer.write(',');
}
Reported by PMD.
Line: 57
}
writer.write(function);
writer.write('(');
for (int i = 0; i < parameters.size(); ++i) {
if (i != 0) {
writer.write(',');
}
serializer.write(parameters.get(i));
Reported by PMD.
Line: 64
}
serializer.write(parameters.get(i));
}
writer.write(')');
}
public String toString() {
return JSON.toJSONString(this);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue166.java
4 issues
Line: 20
SerializerFeature.WriteNonStringKeyAsString, SerializerFeature.QuoteFieldNames,
SerializerFeature.SkipTransientField, SerializerFeature.SortField,
SerializerFeature.PrettyFormat);
System.out.println(text);
VO vo2 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getbId(), vo2.getbId());
}
Reported by PMD.
Line: 12
public class Issue166 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setbId("xxxx");
String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteEnumUsingToString,
SerializerFeature.WriteNonStringKeyAsString, SerializerFeature.QuoteFieldNames,
Reported by PMD.
Line: 24
VO vo2 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getbId(), vo2.getbId());
}
public static class VO {
private String bId;
Reported by PMD.
Line: 29
public static class VO {
private String bId;
public String getbId() {
return bId;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/annotation/CustomDeserializerTest.java
4 issues
Line: 16
import junit.framework.TestCase;
public class CustomDeserializerTest extends TestCase {
public void test_0() throws Exception {
String text = "{\"xid\":1001}";
Model model = JSON.parseObject(text, Model.class);
Assert.assertEquals(1001, model.id);
}
Reported by PMD.
Line: 24
@JSONType(deserializer=ModelDeserializer.class)
public static class Model {
public int id;
}
public static class ModelDeserializer implements ObjectDeserializer {
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
Reported by PMD.
Line: 34
reader.startObject();
String key = reader.readString();
Integer value = reader.readInteger();
Model model = new Model();
model.id = value;
Reported by PMD.
Line: 34
reader.startObject();
String key = reader.readString();
Integer value = reader.readInteger();
Model model = new Model();
model.id = value;
Reported by PMD.