The following issues were found
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectK1_C.java
4 issues
Line: 8
public class ObjectK1_C {
private int a = 0;
private int b = 0;
Reported by PMD.
Line: 10
public class ObjectK1_C {
private int a = 0;
private int b = 0;
private boolean c = false;
Reported by PMD.
Line: 12
private int a = 0;
private int b = 0;
private boolean c = false;
public int getA() {
return a;
Reported by PMD.
Line: 14
private int b = 0;
private boolean c = false;
public int getA() {
return a;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/TestList.java
4 issues
Line: 16
public class TestList extends TestCase {
public void test_0() throws Exception {
VO o = new VO();
o.setId(123);
{
Map<String, List<String>> item = new HashMap<String, List<String>>();
item.put("1", Arrays.asList("a1", "b1"));
Reported by PMD.
Line: 22
{
Map<String, List<String>> item = new HashMap<String, List<String>>();
item.put("1", Arrays.asList("a1", "b1"));
o.getItems().add(item);
}
{
Map<String, List<String>> item = new HashMap<String, List<String>>();
item.put("2", Arrays.asList("a2", "b2"));
o.getItems().add(item);
Reported by PMD.
Line: 27
{
Map<String, List<String>> item = new HashMap<String, List<String>>();
item.put("2", Arrays.asList("a2", "b2"));
o.getItems().add(item);
}
String text = JSON.toJSONString(o);
VO o1 = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 39
Assert.assertEquals("{\"id\":123,\"items\":[{\"1\":[\"a1\",\"b1\"]},{\"2\":[\"a2\",\"b2\"]}]}", text);
}
public static class VO {
private int id;
private List<Map<String, List<String>>> items = new ArrayList<Map<String, List<String>>>();
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_generic_1.java
4 issues
Line: 12
public class Bug_for_generic_1 extends TestCase {
public void test() {
String json2 = "{\"@type\":\"cn.com.tx.domain.pagination.Pagination\",\"fromIndex\":0,\"list\":[{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"61354557\",\"依依\",\"六\"],\"destId\":60721687,\"detailId\":3155063,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344530416000},\"hotId\":0,\"srcId\":1000,\"templateId\":482},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"14527269\",\"懒洋洋\",\"///最佳拍档,非常\",\"24472950\"],\"destId\":60721687,\"detailId\":3151609,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344354485000},\"hotId\":0,\"srcId\":1000,\"templateId\":40},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51090218\",\"天之涯\",\"天会黑,人会变。三分\"],\"destId\":60721687,\"detailId\":3149221,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247529000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51687981\",\"摹然回首梦已成年\",\"星星在哪里都很亮的,\"],\"destId\":60721687,\"detailId\":3149173,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247414000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"41486427\",\"寒江蓑笠\",\"双休了\"],\"destId\":60721687,\"detailId\":3148148,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344244730000},\"hotId\":0,\"srcId\":1000,\"templateId\":459}],\"maxLength\":5,\"nextPage\":2,\"pageIndex\":1,\"prevPage\":1,\"toIndex\":5,\"totalPage\":3,\"totalResult\":13}";
cn.com.tx.domain.pagination.Pagination<cn.com.tx.domain.notifyDetail.NotifyDetail> pagination = JSON.parseObject(json2,
new TypeReference<Pagination<NotifyDetail>>() {
});
Reported by PMD.
Line: 12
public class Bug_for_generic_1 extends TestCase {
public void test() {
String json2 = "{\"@type\":\"cn.com.tx.domain.pagination.Pagination\",\"fromIndex\":0,\"list\":[{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"61354557\",\"依依\",\"六\"],\"destId\":60721687,\"detailId\":3155063,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344530416000},\"hotId\":0,\"srcId\":1000,\"templateId\":482},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"14527269\",\"懒洋洋\",\"///最佳拍档,非常\",\"24472950\"],\"destId\":60721687,\"detailId\":3151609,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344354485000},\"hotId\":0,\"srcId\":1000,\"templateId\":40},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51090218\",\"天之涯\",\"天会黑,人会变。三分\"],\"destId\":60721687,\"detailId\":3149221,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247529000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51687981\",\"摹然回首梦已成年\",\"星星在哪里都很亮的,\"],\"destId\":60721687,\"detailId\":3149173,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247414000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"41486427\",\"寒江蓑笠\",\"双休了\"],\"destId\":60721687,\"detailId\":3148148,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344244730000},\"hotId\":0,\"srcId\":1000,\"templateId\":459}],\"maxLength\":5,\"nextPage\":2,\"pageIndex\":1,\"prevPage\":1,\"toIndex\":5,\"totalPage\":3,\"totalResult\":13}";
cn.com.tx.domain.pagination.Pagination<cn.com.tx.domain.notifyDetail.NotifyDetail> pagination = JSON.parseObject(json2,
new TypeReference<Pagination<NotifyDetail>>() {
});
Reported by PMD.
Line: 14
public void test() {
String json2 = "{\"@type\":\"cn.com.tx.domain.pagination.Pagination\",\"fromIndex\":0,\"list\":[{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"61354557\",\"依依\",\"六\"],\"destId\":60721687,\"detailId\":3155063,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344530416000},\"hotId\":0,\"srcId\":1000,\"templateId\":482},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"14527269\",\"懒洋洋\",\"///最佳拍档,非常\",\"24472950\"],\"destId\":60721687,\"detailId\":3151609,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344354485000},\"hotId\":0,\"srcId\":1000,\"templateId\":40},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51090218\",\"天之涯\",\"天会黑,人会变。三分\"],\"destId\":60721687,\"detailId\":3149221,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247529000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51687981\",\"摹然回首梦已成年\",\"星星在哪里都很亮的,\"],\"destId\":60721687,\"detailId\":3149173,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247414000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"41486427\",\"寒江蓑笠\",\"双休了\"],\"destId\":60721687,\"detailId\":3148148,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344244730000},\"hotId\":0,\"srcId\":1000,\"templateId\":459}],\"maxLength\":5,\"nextPage\":2,\"pageIndex\":1,\"prevPage\":1,\"toIndex\":5,\"totalPage\":3,\"totalResult\":13}";
cn.com.tx.domain.pagination.Pagination<cn.com.tx.domain.notifyDetail.NotifyDetail> pagination = JSON.parseObject(json2,
new TypeReference<Pagination<NotifyDetail>>() {
});
}
}
Reported by PMD.
Line: 14
public void test() {
String json2 = "{\"@type\":\"cn.com.tx.domain.pagination.Pagination\",\"fromIndex\":0,\"list\":[{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"61354557\",\"依依\",\"六\"],\"destId\":60721687,\"detailId\":3155063,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344530416000},\"hotId\":0,\"srcId\":1000,\"templateId\":482},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"14527269\",\"懒洋洋\",\"///最佳拍档,非常\",\"24472950\"],\"destId\":60721687,\"detailId\":3151609,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344354485000},\"hotId\":0,\"srcId\":1000,\"templateId\":40},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51090218\",\"天之涯\",\"天会黑,人会变。三分\"],\"destId\":60721687,\"detailId\":3149221,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247529000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"51687981\",\"摹然回首梦已成年\",\"星星在哪里都很亮的,\"],\"destId\":60721687,\"detailId\":3149173,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344247414000},\"hotId\":0,\"srcId\":1000,\"templateId\":459},{\"@type\":\"cn.com.tx.domain.notifyDetail.NotifyDetail\",\"args\":[\"41486427\",\"寒江蓑笠\",\"双休了\"],\"destId\":60721687,\"detailId\":3148148,\"display\":false,\"foundTime\":{\"@type\":\"java.sql.Timestamp\",\"val\":1344244730000},\"hotId\":0,\"srcId\":1000,\"templateId\":459}],\"maxLength\":5,\"nextPage\":2,\"pageIndex\":1,\"prevPage\":1,\"toIndex\":5,\"totalPage\":3,\"totalResult\":13}";
cn.com.tx.domain.pagination.Pagination<cn.com.tx.domain.notifyDetail.NotifyDetail> pagination = JSON.parseObject(json2,
new TypeReference<Pagination<NotifyDetail>>() {
});
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_ArrayMember.java
4 issues
Line: 9
import junit.framework.TestCase;
public class Bug_for_ArrayMember extends TestCase {
public void test_arrayMember() throws Exception {
A a = new A();
a.setValues(new B[] {new B()});
String text = JSON.toJSONString(a);
Reported by PMD.
Line: 28
private B[] values;
public B[] getValues() {
return values;
}
public void setValues(B[] values) {
this.values = values;
}
Reported by PMD.
Line: 31
return values;
}
public void setValues(B[] values) {
this.values = values;
}
}
Reported by PMD.
Line: 31
return values;
}
public void setValues(B[] values) {
this.values = values;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue_611.java
4 issues
Line: 11
import junit.framework.TestCase;
public class Issue_611 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"priority\":1}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(1, obj.getInteger("priority").intValue());
Assert.assertEquals(1, obj.getIntValue("priority"));
}
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String text = "{\"priority\":1}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(1, obj.getInteger("priority").intValue());
Assert.assertEquals(1, obj.getIntValue("priority"));
}
}
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String text = "{\"priority\":1}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(1, obj.getInteger("priority").intValue());
Assert.assertEquals(1, obj.getIntValue("priority"));
}
}
Reported by PMD.
Line: 15
String text = "{\"priority\":1}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(1, obj.getInteger("priority").intValue());
Assert.assertEquals(1, obj.getIntValue("priority"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/TestType.java
4 issues
Line: 11
public class TestType extends TestCase {
public void test_getType() throws Exception {
Assert.assertEquals(Type.VOID_TYPE, Type.getType(ASMUtils.desc(void.class)));
Assert.assertEquals(Type.BOOLEAN_TYPE, Type.getType(ASMUtils.desc(boolean.class)));
Assert.assertEquals(Type.CHAR_TYPE, Type.getType(ASMUtils.desc(char.class)));
Reported by PMD.
Line: 30
Assert.assertEquals(Type.DOUBLE_TYPE, Type.getType(ASMUtils.desc(double.class)));
Assert.assertEquals("[D", Type.getType(ASMUtils.desc(double[].class)).getInternalName());
Assert.assertEquals("[[D", Type.getType(ASMUtils.desc(double[][].class)).getInternalName());
Assert.assertEquals("[Ljava/lang/Double;", Type.getType(ASMUtils.desc(Double[].class)).getInternalName());
}
}
Reported by PMD.
Line: 31
Assert.assertEquals(Type.DOUBLE_TYPE, Type.getType(ASMUtils.desc(double.class)));
Assert.assertEquals("[D", Type.getType(ASMUtils.desc(double[].class)).getInternalName());
Assert.assertEquals("[[D", Type.getType(ASMUtils.desc(double[][].class)).getInternalName());
Assert.assertEquals("[Ljava/lang/Double;", Type.getType(ASMUtils.desc(Double[].class)).getInternalName());
}
}
Reported by PMD.
Line: 32
Assert.assertEquals("[D", Type.getType(ASMUtils.desc(double[].class)).getInternalName());
Assert.assertEquals("[[D", Type.getType(ASMUtils.desc(double[][].class)).getInternalName());
Assert.assertEquals("[Ljava/lang/Double;", Type.getType(ASMUtils.desc(Double[].class)).getInternalName());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_dubbo2.java
4 issues
Line: 12
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Bug_for_dubbo2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_dubbo2");
}
public void test_emptyHashMap() throws Exception {
VO vo = new VO();
Reported by PMD.
Line: 13
public class Bug_for_dubbo2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_dubbo2");
}
public void test_emptyHashMap() throws Exception {
VO vo = new VO();
vo.setValue(new HashMap());
Reported by PMD.
Line: 16
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_dubbo2");
}
public void test_emptyHashMap() throws Exception {
VO vo = new VO();
vo.setValue(new HashMap());
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
JSON.parse(text);
}
Reported by PMD.
Line: 16
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_dubbo2");
}
public void test_emptyHashMap() throws Exception {
VO vo = new VO();
vo.setValue(new HashMap());
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
JSON.parse(text);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/atomic/AtomicBooleanReadOnlyTest.java
4 issues
Line: 13
public class AtomicBooleanReadOnlyTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0(true);
String text = JSON.toJSONString(v);
Assert.assertEquals("{\"value\":true}", text);
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().get(), v.getValue().get());
}
public static class V0 {
private final AtomicBoolean value;
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().get(), v.getValue().get());
}
public static class V0 {
private final AtomicBoolean value;
Reported by PMD.
Line: 21
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue().get(), v.getValue().get());
}
public static class V0 {
private final AtomicBoolean value;
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/BeforeFilter.java
4 issues
Line: 23
JSONSerializer serializer = serializerLocal.get();
char seperator = seperatorLocal.get();
boolean ref = serializer.references.containsKey(value);
serializer.writeKeyValue(seperator, key, value);
if (!ref) {
serializer.references.remove(value);
}
Reported by PMD.
Line: 24
char seperator = seperatorLocal.get();
boolean ref = serializer.references.containsKey(value);
serializer.writeKeyValue(seperator, key, value);
if (!ref) {
serializer.references.remove(value);
}
if (seperator != ',') {
Reported by PMD.
Line: 26
boolean ref = serializer.references.containsKey(value);
serializer.writeKeyValue(seperator, key, value);
if (!ref) {
serializer.references.remove(value);
}
if (seperator != ',') {
seperatorLocal.set(COMMA);
}
Reported by PMD.
Line: 29
serializer.references.remove(value);
}
if (seperator != ',') {
seperatorLocal.set(COMMA);
}
}
public abstract void writeBefore(Object object);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/MaterializedInterfaceTest.java
4 issues
Line: 18
Assert.assertEquals("chris", bean.getName());
String text2 = JSON.toJSONString(bean);
System.out.println(text2);
}
public static interface Bean {
int getId();
Reported by PMD.
Line: 10
public class MaterializedInterfaceTest extends TestCase {
public void test_parse() throws Exception {
String text = "{\"id\":123, \"name\":\"chris\"}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals(123, bean.getId());
Assert.assertEquals("chris", bean.getName());
Reported by PMD.
Line: 14
String text = "{\"id\":123, \"name\":\"chris\"}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals(123, bean.getId());
Assert.assertEquals("chris", bean.getName());
String text2 = JSON.toJSONString(bean);
System.out.println(text2);
}
Reported by PMD.
Line: 15
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals(123, bean.getId());
Assert.assertEquals("chris", bean.getName());
String text2 = JSON.toJSONString(bean);
System.out.println(text2);
}
Reported by PMD.