The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_572_private.java
5 issues
Line: 13
public class Bug_for_issue_572_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = "wenshao";
String text = JSON.toJSONString(model, SerializerFeature.WriteNonStringValueAsString);
Reported by PMD.
Line: 22
Assert.assertEquals("{\"id\":\"1001\",\"name\":\"wenshao\"}", text);
}
public void test_for_issue_1() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = "wenshao";
ValueFilter valueFilter = new ValueFilter() {
Reported by PMD.
Line: 42
Assert.assertEquals("{\"id\":\"1001\",\"name\":\"wenshao\"}", text);
}
private static class Model {
private int id;
private String name;
public int getId() {
Reported by PMD.
Line: 27
model.id = 1001;
model.name = "wenshao";
ValueFilter valueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (value instanceof Number) {
return null;
Reported by PMD.
Line: 27
model.id = 1001;
model.name = "wenshao";
ValueFilter valueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (value instanceof Number) {
return null;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_Issue_603.java
5 issues
Line: 17
public class Bug_for_Issue_603 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(OrderActionEnum.class, new OrderActionEnumDeser());
{
Msg msg = JSON.parseObject("{\"actionEnum\":1,\"body\":\"A\"}", Msg.class);
Assert.assertEquals(msg.body, "A");
Reported by PMD.
Line: 38
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
Integer intValue = parser.parseObject(int.class);
if (intValue == 1) {
return (T) OrderActionEnum.FAIL;
} else if (intValue == 0) {
return (T) OrderActionEnum.SUCC;
}
throw new IllegalStateException();
Reported by PMD.
Line: 56
public static enum OrderActionEnum {
FAIL(1), SUCC(0);
private int code;
OrderActionEnum(int code){
this.code = code;
}
}
Reported by PMD.
Line: 65
public static class Msg {
public OrderActionEnum actionEnum;
public String body;
}
}
Reported by PMD.
Line: 66
public static class Msg {
public OrderActionEnum actionEnum;
public String body;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_427.java
5 issues
Line: 12
public class Bug_for_issue_427 extends TestCase {
public void test_for_issue() throws Exception {
String value = "================================================"
+ "\n服务器名称:[FFFF00]N23-物华天宝 [-]"
+ "\n开服时间:[FFFF00]2015年10月16日11:00(周五)[-]"
+ "\n================================================";
Reported by PMD.
Line: 12
public class Bug_for_issue_427 extends TestCase {
public void test_for_issue() throws Exception {
String value = "================================================"
+ "\n服务器名称:[FFFF00]N23-物华天宝 [-]"
+ "\n开服时间:[FFFF00]2015年10月16日11:00(周五)[-]"
+ "\n================================================";
Reported by PMD.
Line: 25
public static class Model {
public String value;
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.bug;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
Reported by PMD.
Line: 6
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
public class Bug_for_issue_427 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_SpitFire_3.java
5 issues
Line: 15
q.setHeader("Sdfdf");
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parseObject(text, Generic.class);
}
public static abstract class AbstractDTO {
Reported by PMD.
Line: 10
public class Bug_for_SpitFire_3 extends TestCase {
public void test_for_SpitFire() {
Generic<Payload> q = new Generic<Payload>();
q.setHeader("Sdfdf");
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 10
public class Bug_for_SpitFire_3 extends TestCase {
public void test_for_SpitFire() {
Generic<Payload> q = new Generic<Payload>();
q.setHeader("Sdfdf");
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 19
JSON.parseObject(text, Generic.class);
}
public static abstract class AbstractDTO {
private String test;
public String getTest() {
return test;
Reported by PMD.
Line: 36
}
public static class Generic<T extends AbstractDTO> extends AbstractDTO {
String header;
T payload;
public String getHeader() {
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/ArraySerializer.java
5 issues
Line: 26
*/
public class ArraySerializer implements ObjectSerializer {
private final Class<?> componentType;
private final ObjectSerializer compObjectSerializer;
public ArraySerializer(Class<?> componentType, ObjectSerializer compObjectSerializer){
this.componentType = componentType;
this.compObjectSerializer = compObjectSerializer;
Reported by PMD.
Line: 27
public class ArraySerializer implements ObjectSerializer {
private final Class<?> componentType;
private final ObjectSerializer compObjectSerializer;
public ArraySerializer(Class<?> componentType, ObjectSerializer compObjectSerializer){
this.componentType = componentType;
this.compObjectSerializer = compObjectSerializer;
}
Reported by PMD.
Line: 63
} else {
out.append("null");
}
} else if (item.getClass() == componentType) {
compObjectSerializer.write(serializer, item, i, null, 0);
} else {
ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
itemSerializer.write(serializer, item, i, null, 0);
}
Reported by PMD.
Line: 66
} else if (item.getClass() == componentType) {
compObjectSerializer.write(serializer, item, i, null, 0);
} else {
ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
itemSerializer.write(serializer, item, i, null, 0);
}
}
out.append(']');
} finally {
Reported by PMD.
Line: 67
compObjectSerializer.write(serializer, item, i, null, 0);
} else {
ObjectSerializer itemSerializer = serializer.getObjectWriter(item.getClass());
itemSerializer.write(serializer, item, i, null, 0);
}
}
out.append(']');
} finally {
serializer.context = context;
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectJ1.java
5 issues
Line: 9
import java.util.List;
public class ObjectJ1 {
private int a = 0;
private int b = 0;
Reported by PMD.
Line: 11
public class ObjectJ1 {
private int a = 0;
private int b = 0;
private List<ObjectJ1_A> c;
Reported by PMD.
Line: 13
private int a = 0;
private int b = 0;
private List<ObjectJ1_A> c;
private int d = 0;
Reported by PMD.
Line: 17
private List<ObjectJ1_A> c;
private int d = 0;
private List<CommonObject> e;
private List<Integer> f;
Reported by PMD.
Line: 27
private List<Integer> h;
private boolean i = false;
public int getA() {
return a;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_alibank.java
5 issues
Line: 11
public class Bug_for_alibank extends TestCase {
public void test_bug() throws Exception {
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
System.out.println(jsonStrz);
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
System.out.println(JSON.toJSONString(o));
}
}
Reported by PMD.
Line: 13
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
System.out.println(jsonStrz);
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
System.out.println(JSON.toJSONString(o));
}
}
Reported by PMD.
Line: 9
public class Bug_for_alibank extends TestCase {
public void test_bug() throws Exception {
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
System.out.println(jsonStrz);
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
System.out.println(JSON.toJSONString(o));
}
Reported by PMD.
Line: 9
public class Bug_for_alibank extends TestCase {
public void test_bug() throws Exception {
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
System.out.println(jsonStrz);
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
System.out.println(JSON.toJSONString(o));
}
Reported by PMD.
Line: 12
public void test_bug() throws Exception {
String jsonStrz = "{addContact:[{\"address\":\"=\\\\\\\\\\\'\'\\");|]*{%0d%0a<%00\"}]}";
System.out.println(jsonStrz);
Object o = JSON.parseObject(jsonStrz.replaceAll("\\\\", ""));
System.out.println(JSON.toJSONString(o));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_285.java
5 issues
Line: 12
public class Bug_for_issue_285 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.v1 = new V1();
vo.v1.v2 = new V2();
vo.v1.v2.v3 = new V3();
vo.v1.v2.v3.v4 = new V4();
Reported by PMD.
Line: 27
public static class VO {
public V1 v1;
}
public static class V1 {
public V2 v2;
Reported by PMD.
Line: 32
public static class V1 {
public V2 v2;
}
public static class V2 {
public V3 v3;
Reported by PMD.
Line: 37
public static class V2 {
public V3 v3;
}
public static class V3 {
public V4 v4;
}
Reported by PMD.
Line: 41
}
public static class V3 {
public V4 v4;
}
public static class V4 {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_bbl.java
5 issues
Line: 23
String s001 = JSON.toJSONString(params, SerializerFeature.BrowserCompatible);
System.out.println(s001);
Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
Assert.assertEquals(params.size(), params2.size());
Assert.assertEquals(params.get("uid"), params2.get("uid"));
Reported by PMD.
Line: 14
public class Bug_for_bbl extends TestCase {
public void test_bug() throws Exception {
Map<Object, Object> params = new HashMap<Object, Object>();
params.put("msg",
"<img class=\"em\" src=\"http://ab.com/12/33.jpg\" />");
params.put("uid", "22034343");
Reported by PMD.
Line: 26
System.out.println(s001);
Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
Assert.assertEquals(params.size(), params2.size());
Assert.assertEquals(params.get("uid"), params2.get("uid"));
Assert.assertEquals(params.get("msg"), params2.get("msg"));
Assert.assertEquals(params, params2);
}
Reported by PMD.
Line: 27
Map<Object, Object> params2 = (Map<Object, Object>) JSON.parse(s001);
Assert.assertEquals(params.size(), params2.size());
Assert.assertEquals(params.get("uid"), params2.get("uid"));
Assert.assertEquals(params.get("msg"), params2.get("msg"));
Assert.assertEquals(params, params2);
}
}
Reported by PMD.
Line: 29
Assert.assertEquals(params.size(), params2.size());
Assert.assertEquals(params.get("uid"), params2.get("uid"));
Assert.assertEquals(params.get("msg"), params2.get("msg"));
Assert.assertEquals(params, params2);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue_748.java
5 issues
Line: 13
import junit.framework.TestCase;
public class Issue_748 extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
}
public void testJsonObjectWithClassName() {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 14
public class Issue_748 extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
}
public void testJsonObjectWithClassName() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key1", "value1");
Reported by PMD.
Line: 17
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue_748.");
}
public void testJsonObjectWithClassName() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key1", "value1");
jsonObject.put("key2", "value2");
DataObject dataObject = new DataObject();
dataObject.setValue(jsonObject);
Reported by PMD.
Line: 30
DataObject obj = (DataObject) JSON.parse(jsonStr, Feature.IgnoreNotMatch);
Assert.assertNotNull(obj.value);
Assert.assertNotNull(obj.value.get("key1"));
Assert.assertNotNull(obj.value.get("key2"));
}
public static class DataObject {
Reported by PMD.
Line: 31
DataObject obj = (DataObject) JSON.parse(jsonStr, Feature.IgnoreNotMatch);
Assert.assertNotNull(obj.value);
Assert.assertNotNull(obj.value.get("key1"));
Assert.assertNotNull(obj.value.get("key2"));
}
public static class DataObject {
private JSONObject value;
Reported by PMD.