The following issues were found
src/test/java/com/alibaba/json/bvt/JSONObjectTest7.java
7 issues
Line: 9
public class JSONObjectTest7 extends TestCase {
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
Reported by PMD.
Line: 9
public class JSONObjectTest7 extends TestCase {
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
Reported by PMD.
Line: 11
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
}
Reported by PMD.
Line: 11
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
}
Reported by PMD.
Line: 11
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
}
Reported by PMD.
Line: 12
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
}
Reported by PMD.
Line: 12
public void test() throws Exception {
JSONObject jsonObject = JSON.parseObject("{\"test\":null,\"a\":\"cc\"}");
assertEquals(2, jsonObject.entrySet().size());
assertTrue(jsonObject.containsKey("test"));
}
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/config/FastJsonConfig.java
7 issues
Line: 29
* @since 1.2.11
*/
public class FastJsonConfig {
/**
* default charset
*/
private Charset charset;
Reported by PMD.
Line: 133
* @return the serializerFeatures
*/
public SerializerFeature[] getSerializerFeatures() {
return serializerFeatures;
}
/**
* @param serializerFeatures the serializerFeatures to set
*/
Reported by PMD.
Line: 139
/**
* @param serializerFeatures the serializerFeatures to set
*/
public void setSerializerFeatures(SerializerFeature... serializerFeatures) {
this.serializerFeatures = serializerFeatures;
}
/**
* @return the serializeFilters
Reported by PMD.
Line: 147
* @return the serializeFilters
*/
public SerializeFilter[] getSerializeFilters() {
return serializeFilters;
}
/**
* @param serializeFilters the serializeFilters to set
*/
Reported by PMD.
Line: 153
/**
* @param serializeFilters the serializeFilters to set
*/
public void setSerializeFilters(SerializeFilter... serializeFilters) {
this.serializeFilters = serializeFilters;
}
/**
* @return the features
Reported by PMD.
Line: 161
* @return the features
*/
public Feature[] getFeatures() {
return features;
}
/**
* @param features the features to set
*/
Reported by PMD.
Line: 167
/**
* @param features the features to set
*/
public void setFeatures(Feature... features) {
this.features = features;
}
/**
* @return the classSerializeFilters
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_long_whitespace.java
7 issues
Line: 13
String json = "{\"f1\":11222509, \"f2\":7}";
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
}
public static class VO {
Reported by PMD.
Line: 14
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
}
public static class VO {
Reported by PMD.
Line: 9
public class Bug_for_long_whitespace extends TestCase {
public void test() throws Exception {
String json = "{\"f1\":11222509, \"f2\":7}";
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
Reported by PMD.
Line: 9
public class Bug_for_long_whitespace extends TestCase {
public void test() throws Exception {
String json = "{\"f1\":11222509, \"f2\":7}";
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
Reported by PMD.
Line: 13
String json = "{\"f1\":11222509, \"f2\":7}";
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
}
public static class VO {
Reported by PMD.
Line: 14
VO v = JSON.parseObject(json, VO.class);
System.out.println(v.getF1());
System.out.println(v.getF2());
}
public static class VO {
Reported by PMD.
Line: 18
}
public static class VO {
private long f1;
private int f2;
public long getF1() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/IntTest.java
7 issues
Line: 12
import junit.framework.TestCase;
public class IntTest extends TestCase {
public void test_array() throws Exception {
int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
String text = JSON.toJSONString(values);
long[] values_2 = JSON.parseObject(text, long[].class);
assertEquals(values_2.length, values.length);
for (int i = 0; i < values.length; ++i) {
Reported by PMD.
Line: 12
import junit.framework.TestCase;
public class IntTest extends TestCase {
public void test_array() throws Exception {
int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
String text = JSON.toJSONString(values);
long[] values_2 = JSON.parseObject(text, long[].class);
assertEquals(values_2.length, values.length);
for (int i = 0; i < values.length; ++i) {
Reported by PMD.
Line: 16
int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
String text = JSON.toJSONString(values);
long[] values_2 = JSON.parseObject(text, long[].class);
assertEquals(values_2.length, values.length);
for (int i = 0; i < values.length; ++i) {
assertEquals(values[i], values_2[i]);
}
}
Reported by PMD.
Line: 18
long[] values_2 = JSON.parseObject(text, long[].class);
assertEquals(values_2.length, values.length);
for (int i = 0; i < values.length; ++i) {
assertEquals(values[i], values_2[i]);
}
}
public void test_map() throws Exception {
int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
Reported by PMD.
Line: 22
}
}
public void test_map() throws Exception {
int[] values = new int[] {Integer.MIN_VALUE, -1, 0, 1, Integer.MAX_VALUE};
Map<String, Object> map = new HashMap<String, Object>();
for (int i = 0; i < values.length; ++i) {
map.put(Integer.toString(i), values[i]);
}
Reported by PMD.
Line: 32
String text = JSON.toJSONString(map);
JSONObject obj = JSON.parseObject(text);
for (int i = 0; i < values.length; ++i) {
assertEquals(values[i], ((Number) obj.get(Integer.toString(i))).intValue());
}
}
}
Reported by PMD.
Line: 30
}
String text = JSON.toJSONString(map);
JSONObject obj = JSON.parseObject(text);
for (int i = 0; i < values.length; ++i) {
assertEquals(values[i], ((Number) obj.get(Integer.toString(i))).intValue());
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue96.java
7 issues
Line: 22
}.getType();
// this is ok
Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
System.out.println(page1.sub.getClass());
}
public void xx_testCast() {
Page<Sub> page = new Page<Sub>(new Sub(1));
Type type = new TypeReference<Page<Sub>>() {
Reported by PMD.
Line: 33
// !!!! this will fail:
// !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
System.out.println(page1.sub.getClass());
}
static class Page<T> {
public Page(){
Reported by PMD.
Line: 16
public class Issue96 extends TestCase {
public void test_for_issue() throws Exception {
Page<Sub> page = new Page<Sub>(new Sub(1));
Type type = new TypeReference<Page<Sub>>() {
}.getType();
// this is ok
Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
Reported by PMD.
Line: 16
public class Issue96 extends TestCase {
public void test_for_issue() throws Exception {
Page<Sub> page = new Page<Sub>(new Sub(1));
Type type = new TypeReference<Page<Sub>>() {
}.getType();
// this is ok
Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
Reported by PMD.
Line: 22
}.getType();
// this is ok
Page<Sub> page1 = JSON.parseObject(JSON.toJSONString(page), type);
System.out.println(page1.sub.getClass());
}
public void xx_testCast() {
Page<Sub> page = new Page<Sub>(new Sub(1));
Type type = new TypeReference<Page<Sub>>() {
Reported by PMD.
Line: 33
// !!!! this will fail:
// !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
System.out.println(page1.sub.getClass());
}
static class Page<T> {
public Page(){
Reported by PMD.
Line: 7
import junit.framework.TestCase;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.TypeUtils;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue117.java
7 issues
Line: 15
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
public static interface VO {
Reported by PMD.
Line: 11
public class Issue117 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Reported by PMD.
Line: 13
public class Issue117 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
Reported by PMD.
Line: 15
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
public static interface VO {
Reported by PMD.
Line: 16
Assert.assertEquals(123, vo.getId());
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
public static interface VO {
public int getId();
Reported by PMD.
Line: 17
vo.setId(124);
vo.equals(null);
vo.hashCode();
Assert.assertEquals("{\"id\":124}", vo.toString());
}
public static interface VO {
public int getId();
public void setId(int val);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_smoothrat9.java
7 issues
Line: 21
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"java.util.LinkedHashMap\",1:\"a\",2:\"b\"}",
text);
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Reported by PMD.
Line: 14
public class Bug_for_smoothrat9 extends TestCase {
public void test_set() throws Exception {
Map<Integer, Object> map = new LinkedHashMap<Integer, Object>();
map.put(1, "a");
map.put(2, "b");
Reported by PMD.
Line: 27
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Assert.assertEquals(map.getClass(), value.getClass());
Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
}
public static class Entity {
Reported by PMD.
Line: 28
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Assert.assertEquals(map.getClass(), value.getClass());
Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
}
public static class Entity {
Reported by PMD.
Line: 28
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Assert.assertEquals(map.getClass(), value.getClass());
Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
}
public static class Entity {
Reported by PMD.
Line: 28
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Assert.assertEquals(map.getClass(), value.getClass());
Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
}
public static class Entity {
Reported by PMD.
Line: 28
Map<Integer, Object> value = (Map<Integer, Object>) JSON.parse(text);
Assert.assertEquals(map, value);
Assert.assertEquals(map.getClass(), value.getClass());
Assert.assertEquals(Integer.class, value.keySet().iterator().next().getClass());
}
public static class Entity {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue274.java
7 issues
Line: 18
cus.setName("name");
Object json = JSON.toJSON(cus);
System.out.println(json);
String cusJson = json.toString();
cusJson = "{\"name\":\"name\",\"id\":1}";
Reported by PMD.
Line: 26
Customer customer = JSON.parseObject(cusJson, Customer.class);
System.out.println(customer);
}
public interface Indexable<ID extends Serializable> {
public ID getId();
Reported by PMD.
Line: 12
public class Issue274 extends TestCase {
public void test() throws Exception {
Customer cus = new Customer();
cus.setId(1L);
cus.setName("name");
Object json = JSON.toJSON(cus);
Reported by PMD.
Line: 12
public class Issue274 extends TestCase {
public void test() throws Exception {
Customer cus = new Customer();
cus.setId(1L);
cus.setName("name");
Object json = JSON.toJSON(cus);
Reported by PMD.
Line: 20
Object json = JSON.toJSON(cus);
System.out.println(json);
String cusJson = json.toString();
cusJson = "{\"name\":\"name\",\"id\":1}";
Customer customer = JSON.parseObject(cusJson, Customer.class);
Reported by PMD.
Line: 20
Object json = JSON.toJSON(cus);
System.out.println(json);
String cusJson = json.toString();
cusJson = "{\"name\":\"name\",\"id\":1}";
Customer customer = JSON.parseObject(cusJson, Customer.class);
Reported by PMD.
Line: 20
Object json = JSON.toJSON(cus);
System.out.println(json);
String cusJson = json.toString();
cusJson = "{\"name\":\"name\",\"id\":1}";
Customer customer = JSON.parseObject(cusJson, Customer.class);
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/GuavaCodec.java
7 issues
Line: 23
public static GuavaCodec instance = new GuavaCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof Multimap) {
Multimap multimap = (Multimap) object;
serializer.write(multimap.asMap());
}
}
Reported by PMD.
Line: 26
SerializeWriter out = serializer.out;
if (object instanceof Multimap) {
Multimap multimap = (Multimap) object;
serializer.write(multimap.asMap());
}
}
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
Type rawType = type;
Reported by PMD.
Line: 39
if (rawType == ArrayListMultimap.class) {
ArrayListMultimap multimap = ArrayListMultimap.create();
JSONObject object = parser.parseObject();
for (Map.Entry entry : object.entrySet()) {
Object value = entry.getValue();
if (value instanceof Collection) {
multimap.putAll(entry.getKey(), (List) value);
} else {
multimap.put(entry.getKey(), value);
Reported by PMD.
Line: 42
for (Map.Entry entry : object.entrySet()) {
Object value = entry.getValue();
if (value instanceof Collection) {
multimap.putAll(entry.getKey(), (List) value);
} else {
multimap.put(entry.getKey(), value);
}
}
Reported by PMD.
Line: 44
if (value instanceof Collection) {
multimap.putAll(entry.getKey(), (List) value);
} else {
multimap.put(entry.getKey(), value);
}
}
return (T) multimap;
}
Reported by PMD.
Line: 23
public static GuavaCodec instance = new GuavaCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof Multimap) {
Multimap multimap = (Multimap) object;
serializer.write(multimap.asMap());
}
}
Reported by PMD.
Line: 31
}
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
Type rawType = type;
if (type instanceof ParameterizedType) {
rawType = ((ParameterizedType) type).getRawType();
}
if (rawType == ArrayListMultimap.class) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_wtusmchen.java
7 issues
Line: 21
users.add(new User());
String text = JSON.toJSONString(users);
System.out.println(text);
List<User> users2 = JSON.parseArray(text, User.class);
}
public static class User implements Serializable {
Reported by PMD.
Line: 15
public class Bug_for_wtusmchen extends TestCase {
public void test_0() throws Exception {
List<User> users = new ArrayList<User>();
users.add(new User());
users.add(new User());
String text = JSON.toJSONString(users);
Reported by PMD.
Line: 15
public class Bug_for_wtusmchen extends TestCase {
public void test_0() throws Exception {
List<User> users = new ArrayList<User>();
users.add(new User());
users.add(new User());
String text = JSON.toJSONString(users);
Reported by PMD.
Line: 23
String text = JSON.toJSONString(users);
System.out.println(text);
List<User> users2 = JSON.parseArray(text, User.class);
}
public static class User implements Serializable {
private String user_id = "aaaa";
Reported by PMD.
Line: 26
List<User> users2 = JSON.parseArray(text, User.class);
}
public static class User implements Serializable {
private String user_id = "aaaa";
Date bri;
Timestamp bri2;
Double num;
Reported by PMD.
Line: 26
List<User> users2 = JSON.parseArray(text, User.class);
}
public static class User implements Serializable {
private String user_id = "aaaa";
Date bri;
Timestamp bri2;
Double num;
Reported by PMD.
Line: 23
String text = JSON.toJSONString(users);
System.out.println(text);
List<User> users2 = JSON.parseArray(text, User.class);
}
public static class User implements Serializable {
private String user_id = "aaaa";
Reported by PMD.