The following issues were found
src/test/java/com/alibaba/json/bvt/ArrayListFieldTest.java
5 issues
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class ArrayListFieldTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 28
V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(v1.getValue(), v.getValue());
}
private static class V0 {
private ArrayList<Object> value;
Reported by PMD.
Line: 33
private static class V0 {
private ArrayList<Object> value;
public ArrayList<Object> getValue() {
return value;
}
Reported by PMD.
Line: 35
private ArrayList<Object> value;
public ArrayList<Object> getValue() {
return value;
}
public void setValue(ArrayList<Object> value) {
this.value = value;
Reported by PMD.
Line: 39
return value;
}
public void setValue(ArrayList<Object> value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_265.java
5 issues
Line: 19
public class Bug_for_issue_265 extends TestCase {
public void test_for_issue() throws Exception {
User user = new User();
user.setName("wenshao");
String text = JSON.toJSONString(user);
Reported by PMD.
Line: 29
}
public void test_for_issue_decode() throws Exception {
String text = "{\"name\":\"wenshao\",\"id\":1001}";
User user = JSON.parseObject(text, User.class);
Assert.assertEquals("wenshao", user.getName());
Assert.assertEquals(1001, user.getAttribute("id"));
Reported by PMD.
Line: 33
String text = "{\"name\":\"wenshao\",\"id\":1001}";
User user = JSON.parseObject(text, User.class);
Assert.assertEquals("wenshao", user.getName());
Assert.assertEquals(1001, user.getAttribute("id"));
}
public static class Model implements JSONSerializable, ExtraProcessable {
Reported by PMD.
Line: 34
User user = JSON.parseObject(text, User.class);
Assert.assertEquals("wenshao", user.getName());
Assert.assertEquals(1001, user.getAttribute("id"));
}
public static class Model implements JSONSerializable, ExtraProcessable {
protected Map<String, Object> attributes = new HashMap<String, Object>();
Reported by PMD.
Line: 39
public static class Model implements JSONSerializable, ExtraProcessable {
protected Map<String, Object> attributes = new HashMap<String, Object>();
public Map<String, Object> getAttributes() {
return attributes;
}
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectK1_A.java
5 issues
Line: 8
public class ObjectK1_A {
private int a = 0;
private int b = 0;
Reported by PMD.
Line: 10
public class ObjectK1_A {
private int a = 0;
private int b = 0;
private int c = 0;
Reported by PMD.
Line: 12
private int a = 0;
private int b = 0;
private int c = 0;
private int d = 0;
Reported by PMD.
Line: 14
private int b = 0;
private int c = 0;
private int d = 0;
public int getA() {
return a;
Reported by PMD.
Line: 16
private int c = 0;
private int d = 0;
public int getA() {
return a;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_242.java
5 issues
Line: 13
final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
VO vo = JSON.parseObject(text, VO.class);
System.out.println(vo);
}
public static class VO {
public int int1;
Reported by PMD.
Line: 9
public class Bug_for_issue_242 extends TestCase {
public void test_true() throws Exception {
final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
VO vo = JSON.parseObject(text, VO.class);
System.out.println(vo);
}
Reported by PMD.
Line: 9
public class Bug_for_issue_242 extends TestCase {
public void test_true() throws Exception {
final String text = "{int1:\"NULL\",int2:\"null\",long1:NULL,long2:null, dou1:\"NULL\",dou2:\"null\",str1:\"NULL\",str2:NULL, bool2:\"NULL\",bool1:null}";
VO vo = JSON.parseObject(text, VO.class);
System.out.println(vo);
}
Reported by PMD.
Line: 16
System.out.println(vo);
}
public static class VO {
public int int1;
public int int2;
public long long1;
public long long2;
Reported by PMD.
Line: 34
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("int1 = ").append(int1)//
.append(" int2 = ").append(int2)//
.append(" long1 = ").append(long1)//
.append(" long2 = ").append(long2)//
.append(" dou1 = ").append(dou1)//
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_generic_huansi.java
5 issues
Line: 10
* Created by wenshao on 19/12/2016.
*/
public class Bug_for_generic_huansi extends TestCase {
public void test_for_issue() throws Exception {
String jsonStr = "{\"id\": 1234}";
SimpleGenericObject jsonObj = JSON.parseObject(jsonStr, SimpleGenericObject.class);
try {
Reported by PMD.
Line: 17
try {
Long id = jsonObj.getId();
assertTrue(id.equals(1234L));
} catch (Exception e) {
fail("parse error:" + e.getMessage());
}
}
Reported by PMD.
Line: 17
try {
Long id = jsonObj.getId();
assertTrue(id.equals(1234L));
} catch (Exception e) {
fail("parse error:" + e.getMessage());
}
}
Reported by PMD.
Line: 17
try {
Long id = jsonObj.getId();
assertTrue(id.equals(1234L));
} catch (Exception e) {
fail("parse error:" + e.getMessage());
}
}
Reported by PMD.
Line: 18
try {
Long id = jsonObj.getId();
assertTrue(id.equals(1234L));
} catch (Exception e) {
fail("parse error:" + e.getMessage());
}
}
public static class BaseGenericType<T> {
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectL1.java
5 issues
Line: 10
import java.util.List;
public class ObjectL1 {
List<ObjectL1_A> a;
int b;
Reported by PMD.
Line: 30
List<CommonObject> h;
HashMap<Integer, HashMap<Integer, ObjectL2_C>> i;
boolean j = false;
public List<ObjectL1_A> getA() {
return a;
Reported by PMD.
Line: 32
HashMap<Integer, HashMap<Integer, ObjectL2_C>> i;
boolean j = false;
public List<ObjectL1_A> getA() {
return a;
}
Reported by PMD.
Line: 98
this.h = h;
}
public HashMap<Integer, HashMap<Integer, ObjectL2_C>> getI() {
return i;
}
public void setI(HashMap<Integer, HashMap<Integer, ObjectL2_C>> i) {
this.i = i;
Reported by PMD.
Line: 102
return i;
}
public void setI(HashMap<Integer, HashMap<Integer, ObjectL2_C>> i) {
this.i = i;
}
public boolean isJ() {
return j;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_dubbo1.java
5 issues
Line: 27
text = JSON.toJSONString(tiger, SerializerFeature.WriteClassName);
}
System.out.println(text);
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
Reported by PMD.
Line: 15
public class Bug_for_dubbo1 extends TestCase {
public void test_0() throws Exception {
String text;
{
HashSet<String> tigers = new HashSet<String>();
tigers.add("老虎二");
tigers.add("老虎大");
Reported by PMD.
Line: 30
System.out.println(text);
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
Line: 31
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
Line: 31
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parse(text);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_dubbo3.java
5 issues
Line: 28
text = JSON.toJSONString(tiger, SerializerFeature.WriteClassName);
}
System.out.println(text);
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
Reported by PMD.
Line: 16
public class Bug_for_dubbo3 extends TestCase {
public void test_0() throws Exception {
String text;
{
HashSet<String> tigers = new HashSet<String>();
tigers.add("老虎二");
tigers.add("老虎大");
Reported by PMD.
Line: 31
System.out.println(text);
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
Line: 32
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
Line: 32
HashMap<String, Collection<String>> tigger2 = (HashMap<String, Collection<String>>) JSON.parseObject(text, Map.class);
Assert.assertEquals(1, tigger2.size());
Assert.assertEquals(2, tigger2.get("老鼠").size());
}
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/JSONObjectCodec.java
5 issues
Line: 17
MapSerializer mapSerializer = MapSerializer.instance;
try {
Field mapField = object.getClass().getDeclaredField("map");
if (Modifier.isPrivate(mapField.getModifiers())) {
mapField.setAccessible(true);
}
Object map = mapField.get(object);
Reported by PMD.
Line: 18
try {
Field mapField = object.getClass().getDeclaredField("map");
if (Modifier.isPrivate(mapField.getModifiers())) {
mapField.setAccessible(true);
}
Object map = mapField.get(object);
mapSerializer.write(serializer, map, fieldName, fieldType, features);
Reported by PMD.
Line: 19
try {
Field mapField = object.getClass().getDeclaredField("map");
if (Modifier.isPrivate(mapField.getModifiers())) {
mapField.setAccessible(true);
}
Object map = mapField.get(object);
mapSerializer.write(serializer, map, fieldName, fieldType, features);
Reported by PMD.
Line: 22
mapField.setAccessible(true);
}
Object map = mapField.get(object);
mapSerializer.write(serializer, map, fieldName, fieldType, features);
} catch (Exception e) {
out.writeNull();
}
Reported by PMD.
Line: 25
Object map = mapField.get(object);
mapSerializer.write(serializer, map, fieldName, fieldType, features);
} catch (Exception e) {
out.writeNull();
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ParseArrayTest.java
5 issues
Line: 14
import com.alibaba.fastjson.JSON;
public class ParseArrayTest extends TestCase {
public void test_0 () throws Exception {
List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
Assert.assertTrue(list.get(0) instanceof TreeMap);
Assert.assertTrue(list.get(1) instanceof HashMap);
}
Reported by PMD.
Line: 15
public class ParseArrayTest extends TestCase {
public void test_0 () throws Exception {
List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
Assert.assertTrue(list.get(0) instanceof TreeMap);
Assert.assertTrue(list.get(1) instanceof HashMap);
}
public void test_1 () throws Exception {
Reported by PMD.
Line: 15
public class ParseArrayTest extends TestCase {
public void test_0 () throws Exception {
List<Object> list = JSON.parseArray("[{}, {}]", new Type[] {TreeMap.class, HashMap.class});
Assert.assertTrue(list.get(0) instanceof TreeMap);
Assert.assertTrue(list.get(1) instanceof HashMap);
}
public void test_1 () throws Exception {
Reported by PMD.
Line: 20
Assert.assertTrue(list.get(1) instanceof HashMap);
}
public void test_1 () throws Exception {
List<Object> list = JSON.parseArray("[1, 2, \"abc\"]", new Type[] {int.class, Integer.class, String.class});
Assert.assertTrue(list.get(0) instanceof Integer);
Assert.assertTrue(list.get(1) instanceof Integer);
Assert.assertTrue(list.get(2) instanceof String);
}
Reported by PMD.
Line: 27
Assert.assertTrue(list.get(2) instanceof String);
}
public void test_2 () throws Exception {
List<Object> list = JSON.parseArray("[1, null, \"abc\"]", new Type[] {int.class, Integer.class, String.class});
Assert.assertTrue(list.get(0) instanceof Integer);
Assert.assertTrue(list.get(1) == null);
Assert.assertTrue(list.get(2) instanceof String);
}
Reported by PMD.