The following issues were found
src/test/java/com/alibaba/json/bvt/EnumFieldTest3_private.java
5 issues
Line: 14
public class EnumFieldTest3_private extends TestCase {
public void test_1() throws Exception {
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = Type.A;
}
Reported by PMD.
Line: 31
}
}
public void test_1_writer() throws Exception {
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = Type.A;
}
Reported by PMD.
Line: 50
}
}
public void test_null() throws Exception {
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = null;
}
Reported by PMD.
Line: 54
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = null;
}
String text = JSON.toJSONString(array, SerializerFeature.WriteMapNullValue);
Model[] array2 = JSON.parseObject(text, Model[].class);
Reported by PMD.
Line: 69
public static class Model {
public Type value;
}
private static enum Type {
A, B, C
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_jial10802.java
5 issues
Line: 30
Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
});
System.out.println(jsonPage.getItems().get(0).getName());
}
}
Reported by PMD.
Line: 16
public class Bug_for_jial10802 extends TestCase {
public void test_for_jial10802() throws Exception {
Page<Bean> page = new Page<Bean>();
page.setCount(1);
List<Bean> items = new ArrayList<Bean>();
Bean item = new Bean();
item.setId(1);
Reported by PMD.
Line: 16
public class Bug_for_jial10802 extends TestCase {
public void test_for_jial10802() throws Exception {
Page<Bean> page = new Page<Bean>();
page.setCount(1);
List<Bean> items = new ArrayList<Bean>();
Bean item = new Bean();
item.setId(1);
Reported by PMD.
Line: 30
Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
});
System.out.println(jsonPage.getItems().get(0).getName());
}
}
Reported by PMD.
Line: 30
Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
});
System.out.println(jsonPage.getItems().get(0).getName());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_729.java
5 issues
Line: 14
public class Bug_for_issue_729 extends TestCase {
public void test_for_issue() throws Exception {
Person person = new Person();
person.setName("bob");
person.startTime = new Date();
String result = JSON.toJSONString(person);
Reported by PMD.
Line: 14
public class Bug_for_issue_729 extends TestCase {
public void test_for_issue() throws Exception {
Person person = new Person();
person.setName("bob");
person.startTime = new Date();
String result = JSON.toJSONString(person);
Reported by PMD.
Line: 21
String result = JSON.toJSONString(person);
Person person2 = JSON.parseObject(result, Person.class);
person2.toString();
}
public static class Person implements Serializable {
public String name;
Reported by PMD.
Line: 24
person2.toString();
}
public static class Person implements Serializable {
public String name;
@JSONField(format = "yyyy-MM-dd HH:mm")
public Date startTime;
Reported by PMD.
Line: 24
person2.toString();
}
public static class Person implements Serializable {
public String name;
@JSONField(format = "yyyy-MM-dd HH:mm")
public Date startTime;
Reported by PMD.
src/test/java/com/alibaba/json/bvtVO/vip_com/QueryLoanOrderRsp.java
5 issues
Line: 84
rsp.setTxn_list(txn_list);
String txt = JSON.toJSONString(rsp);
System.out.println(txt);
String txt2 = JSON.toJSONString(txn_list);
System.out.println(txt2);
List<TxnListItsm> itsms = JSON.parseObject(txt2,
Reported by PMD.
Line: 87
System.out.println(txt);
String txt2 = JSON.toJSONString(txn_list);
System.out.println(txt2);
List<TxnListItsm> itsms = JSON.parseObject(txt2,
new TypeReference<List<TxnListItsm>>(){});
System.out.println(itsms);
Reported by PMD.
Line: 91
List<TxnListItsm> itsms = JSON.parseObject(txt2,
new TypeReference<List<TxnListItsm>>(){});
System.out.println(itsms);
rsp = JSON.parseObject(txt,
new TypeReference<QueryLoanOrderRsp>(){});
System.out.println(rsp);
Reported by PMD.
Line: 96
rsp = JSON.parseObject(txt,
new TypeReference<QueryLoanOrderRsp>(){});
System.out.println(rsp);
}
}
Reported by PMD.
Line: 10
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
public class QueryLoanOrderRsp {
private String loan_card_no;
private String loan_prod_code;
private String last_row_type;//最后一条记录类型
private String last_row_key;//最后一条记录键值
private String nextpage_flag;//是否有下一页标志
Reported by PMD.
src/test/java/com/alibaba/json/demo/EncodeDemo.java
5 issues
Line: 27
String jsonString = JSON.toJSONString(group);
System.out.println(jsonString);
JSON.parseObject(jsonString, Group.class);
}
}
Reported by PMD.
Line: 9
public class EncodeDemo extends TestCase {
public void test_encode() throws Exception {
Group group = new Group();
group.setId(0L);
group.setName("admin");
User guestUser = new User();
Reported by PMD.
Line: 9
public class EncodeDemo extends TestCase {
public void test_encode() throws Exception {
Group group = new Group();
group.setId(0L);
group.setName("admin");
User guestUser = new User();
Reported by PMD.
Line: 22
rootUser.setId(3L);
rootUser.setName("root");
group.getUsers().add(guestUser);
group.getUsers().add(rootUser);
String jsonString = JSON.toJSONString(group);
System.out.println(jsonString);
Reported by PMD.
Line: 23
rootUser.setName("root");
group.getUsers().add(guestUser);
group.getUsers().add(rootUser);
String jsonString = JSON.toJSONString(group);
System.out.println(jsonString);
Reported by PMD.
src/test/java/com/alibaba/json/test/a/AlipayJSONPathReplace.java
5 issues
Line: 11
* Created by wenshao on 06/02/2017.
*/
public class AlipayJSONPathReplace extends TestCase {
public void test_jsonpath() throws Exception {
Model model = new Model();
JSONPath path = JSONPath.compile("/value/id");
path.set(model, 123);
assertNotNull(model.value);
}
Reported by PMD.
Line: 14
public void test_jsonpath() throws Exception {
Model model = new Model();
JSONPath path = JSONPath.compile("/value/id");
path.set(model, 123);
assertNotNull(model.value);
}
public static class Model {
public Value value;
Reported by PMD.
Line: 15
Model model = new Model();
JSONPath path = JSONPath.compile("/value/id");
path.set(model, 123);
assertNotNull(model.value);
}
public static class Model {
public Value value;
}
Reported by PMD.
Line: 19
}
public static class Model {
public Value value;
}
public static class Value {
public int id;
}
Reported by PMD.
Line: 4
package com.alibaba.json.test.a;
import com.alibaba.fastjson.JSONPath;
import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
import junit.framework.TestCase;
/**
* Created by wenshao on 06/02/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_jsonType.java
5 issues
Line: 15
public class WriteAsArray_jsonType extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
Parent parent = new Parent();
Reported by PMD.
Line: 25
String text = JSON.toJSONString(parent);
Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
VO vo2 = JSON.parseObject(text, Parent.class).getVo();
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
}
public static class Parent {
Reported by PMD.
Line: 26
String text = JSON.toJSONString(parent);
Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
VO vo2 = JSON.parseObject(text, Parent.class).getVo();
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
}
public static class Parent {
private VO vo;
Reported by PMD.
Line: 27
Assert.assertEquals("{\"vo\":[123,\"wenshao\"]}", text);
VO vo2 = JSON.parseObject(text, Parent.class).getVo();
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
}
public static class Parent {
private VO vo;
Reported by PMD.
Line: 44
}
@JSONType(serialzeFeatures=SerializerFeature.BeanToArray, parseFeatures=Feature.SupportArrayToBean)
public static class VO {
@JSONField(ordinal=1)
private int id;
@JSONField(ordinal=2)
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/test/tmall/TmallTest.java
5 issues
Line: 18
@SuppressWarnings("deprecation")
public void test_for_tmall() throws Exception {
File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
String text = IOUtils.readAll(new FileReader(file));
for (int i = 0; i < 10; ++i) {
long start = System.currentTimeMillis();
perf(text);
long millis = System.currentTimeMillis() - start;
Reported by PMD.
Line: 24
long start = System.currentTimeMillis();
perf(text);
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
}
private void perf(String text) {
for (int i = 0; i < 1000; ++i) {
Reported by PMD.
Line: 15
* Created by wenshao on 17/03/2017.
*/
public class TmallTest extends TestCase {
@SuppressWarnings("deprecation")
public void test_for_tmall() throws Exception {
File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
String text = IOUtils.readAll(new FileReader(file));
for (int i = 0; i < 10; ++i) {
Reported by PMD.
Line: 16
*/
public class TmallTest extends TestCase {
@SuppressWarnings("deprecation")
public void test_for_tmall() throws Exception {
File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
String text = IOUtils.readAll(new FileReader(file));
for (int i = 0; i < 10; ++i) {
long start = System.currentTimeMillis();
Reported by PMD.
Line: 18
@SuppressWarnings("deprecation")
public void test_for_tmall() throws Exception {
File file = new File("/Users/wenshao/Downloads/tmall_perf/searchjson.json");
String text = IOUtils.readAll(new FileReader(file));
for (int i = 0; i < 10; ++i) {
long start = System.currentTimeMillis();
perf(text);
long millis = System.currentTimeMillis() - start;
Reported by PMD.
src/test/java/com/alibaba/json/test/vans/VansData.java
5 issues
Line: 10
/**
* Created by xiaolin_kxl on 16/12/28.
*/
public class VansData implements Serializable{
public int[] textures;
public ArrayList<String> images;
public VansObject object;
public VansMetaData metadata;
Reported by PMD.
Line: 13
public class VansData implements Serializable{
public int[] textures;
public ArrayList<String> images;
public VansObject object;
public VansMetaData metadata;
public ArrayList<VansGeometry> geometries;
public ArrayList<VansAnimation> animations;
public Object materials;
Reported by PMD.
Line: 16
public ArrayList<String> images;
public VansObject object;
public VansMetaData metadata;
public ArrayList<VansGeometry> geometries;
public ArrayList<VansAnimation> animations;
public Object materials;
}
Reported by PMD.
Line: 17
public VansObject object;
public VansMetaData metadata;
public ArrayList<VansGeometry> geometries;
public ArrayList<VansAnimation> animations;
public Object materials;
}
Reported by PMD.
Line: 5
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by xiaolin_kxl on 16/12/28.
*/
public class VansData implements Serializable{
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain.java
5 issues
Line: 7
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;
public class BenchmarkMain {
public static void main(String[] args) throws Exception {
// 注意,byte[]在jackson中是使用base64编码的,不正确的。
BenchmarkExecutor executor = new BenchmarkExecutor();
executor.setExecuteCount(10);
Reported by PMD.
Line: 8
import com.alibaba.json.test.codec.*;
public class BenchmarkMain {
public static void main(String[] args) throws Exception {
// 注意,byte[]在jackson中是使用base64编码的,不正确的。
BenchmarkExecutor executor = new BenchmarkExecutor();
executor.setExecuteCount(10);
// executor.getCodecList().add(new FastjsonManualCodec());
Reported by PMD.
Line: 3
package com.alibaba.json.test.benchmark;
import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;
public class BenchmarkMain {
public static void main(String[] args) throws Exception {
// 注意,byte[]在jackson中是使用base64编码的,不正确的。
Reported by PMD.
Line: 4
package com.alibaba.json.test.benchmark;
import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;
public class BenchmarkMain {
public static void main(String[] args) throws Exception {
// 注意,byte[]在jackson中是使用base64编码的,不正确的。
Reported by PMD.
Line: 5
import com.alibaba.json.test.benchmark.encode.*;
import com.alibaba.json.test.benchmark.decode.*;
import com.alibaba.json.test.codec.*;
public class BenchmarkMain {
public static void main(String[] args) throws Exception {
// 注意,byte[]在jackson中是使用base64编码的,不正确的。
Reported by PMD.