The following issues were found
src/test/java/com/alibaba/json/test/benchmark/basic/BigDecimalBenchmark.java
5 issues
Line: 39
JSON.parseObject(json, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf2() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 10; ++i) {
Reported by PMD.
Line: 48
JSON.parseObject(json2, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf3() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 10; ++i) {
Reported by PMD.
Line: 57
JSON.parseObject(json3, Model.class, Feature.SupportArrayToBean);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public BigDecimal v1;
public BigDecimal v2;
Reported by PMD.
Line: 11
/**
* Created by wenshao on 04/08/2017.
*/
public class BigDecimalBenchmark {
static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
static String json3 = "[0.4430165316544028,0.22676692048907365,0.9766986818812096,0.3423751102308744,0.4262177938610565]";
public static void main(String[] args) throws Exception {
Reported by PMD.
Line: 16
static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
static String json3 = "[0.4430165316544028,0.22676692048907365,0.9766986818812096,0.3423751102308744,0.4262177938610565]";
public static void main(String[] args) throws Exception {
// Model model = new Model();
// model.v1 = new Random().nextDouble();
// model.v2 = new Random().nextDouble();
// model.v3 = new Random().nextDouble();
// model.v4 = new Random().nextDouble();
Reported by PMD.
src/test/java/com/alibaba/json/bvtVO/alipay/PlatformDepartmentVO.java
5 issues
Line: 8
import java.util.ArrayList;
import java.util.List;
public class PlatformDepartmentVO {
@JSONField(ordinal=1)
private String id ;
@JSONField(ordinal=2)
private String label ;
@JSONField(ordinal=3)
Reported by PMD.
Line: 8
import java.util.ArrayList;
import java.util.List;
public class PlatformDepartmentVO {
@JSONField(ordinal=1)
private String id ;
@JSONField(ordinal=2)
private String label ;
@JSONField(ordinal=3)
Reported by PMD.
Line: 237
// }
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
Reported by PMD.
Line: 251
return false;
}
final PlatformDepartmentVO other = (PlatformDepartmentVO) obj;
if(!this.getId().equals(other.getId())) {
return false;
}
return true;
}
Reported by PMD.
Line: 251
return false;
}
final PlatformDepartmentVO other = (PlatformDepartmentVO) obj;
if(!this.getId().equals(other.getId())) {
return false;
}
return true;
}
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/basic/DoubleBenchmark_obj.java
5 issues
Line: 34
JSON.parseObject(json, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf2() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 10; ++i) {
Reported by PMD.
Line: 43
JSON.parseObject(json2, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public Model() {
Reported by PMD.
Line: 8
/**
* Created by wenshao on 04/08/2017.
*/
public class DoubleBenchmark_obj {
static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
public static void main(String[] args) throws Exception {
// Model model = new Model();
Reported by PMD.
Line: 12
static String json = "{\"v1\":0.4430165316544028,\"v2\":0.22676692048907365,\"v3\":0.9766986818812096,\"v4\":0.3423751102308744,\"v5\":0.4262177938610565}";
static String json2 = "{\"v1\":\"0.4430165316544028\",\"v2\":\"0.22676692048907365\",\"v3\":\"0.9766986818812096\",\"v4\":\"0.3423751102308744\",\"v5\":\"0.4262177938610565\"}";
public static void main(String[] args) throws Exception {
// Model model = new Model();
// model.v1 = new Random().nextDouble();
// model.v2 = new Random().nextDouble();
// model.v3 = new Random().nextDouble();
// model.v4 = new Random().nextDouble();
Reported by PMD.
Line: 46
System.out.println("millis : " + millis);
}
public static class Model {
public Model() {
}
public Double v1;
public Double v2;
Reported by PMD.
src/test/java/com/alibaba/json/test/entity/TestEntity.java
5 issues
Line: 17
private Boolean f2;
private byte f3;
private Byte f4;
private short f5;
private Short f6;
private int f7;
private Integer f8;
private long f9;
private Long f10;
Reported by PMD.
Line: 110
this.f4 = f4;
}
public short getF5() {
return f5;
}
public void setF5(short f5) {
this.f5 = f5;
Reported by PMD.
Line: 114
return f5;
}
public void setF5(short f5) {
this.f5 = f5;
}
public Short getF6() {
return f6;
Reported by PMD.
Line: 1
package com.alibaba.json.test.entity;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
Reported by PMD.
Line: 11
import com.alibaba.fastjson.annotation.JSONField;
public class TestEntity {
private boolean f1;
private Boolean f2;
private byte f3;
private Byte f4;
Reported by PMD.
src/test/java/com/alibaba/json/bvtVO/VirtualTopic.java
5 issues
Line: 6
import java.util.HashMap;
import java.util.Map;
public class VirtualTopic {
private static final long serialVersionUID = 1115397330651723322L;
private Map<Integer, QueueEntity> queueMap = new HashMap<Integer, QueueEntity>();
private Integer queueCount;
Reported by PMD.
Line: 67
}
VirtualTopic vt = (VirtualTopic) other;
int size = queueMap.size();
if (size != vt.queueMap.size()) {
return true;
}
for (Integer id : queueMap.keySet()) {
if (!vt.queueMap.containsKey(id)) {
return true;
Reported by PMD.
Line: 71
return true;
}
for (Integer id : queueMap.keySet()) {
if (!vt.queueMap.containsKey(id)) {
return true;
}
}
return false;
}
Reported by PMD.
Line: 84
}
VirtualTopic vt = (VirtualTopic) other;
int size = queueMap.size();
if (size != vt.queueMap.size()) {
return true;
}
for (Integer id : queueMap.keySet()) {
if (!vt.queueMap.containsKey(id)) {
return true;
Reported by PMD.
Line: 88
return true;
}
for (Integer id : queueMap.keySet()) {
if (!vt.queueMap.containsKey(id)) {
return true;
}
}
return false;
}
Reported by PMD.
src/test/java/data/media/writeAsArray/MediaContentDeserializer.java
5 issues
Line: 18
public class MediaContentDeserializer implements ObjectDeserializer {
MediaDeserializer mediaDeser = new MediaDeserializer();
ImageDeserializer imageDesc = new ImageDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
Reported by PMD.
Line: 19
public class MediaContentDeserializer implements ObjectDeserializer {
MediaDeserializer mediaDeser = new MediaDeserializer();
ImageDeserializer imageDesc = new ImageDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
Reported by PMD.
Line: 23
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
parser.accept(JSONToken.LBRACKET, JSONToken.LBRACKET);
Media media = mediaDeser.deserialze(parser, Media.class, "media");
parser.accept(JSONToken.COMMA, JSONToken.LBRACKET);
Reported by PMD.
Line: 31
parser.accept(JSONToken.LBRACKET, JSONToken.LBRACKET);
List<Image> images = new ArrayList<Image>();
int index = 0;
for (;;) {
Image image = imageDesc.deserialze(parser, Image.class, index);
images.add(image);
index++;
if (lexer.token() == JSONToken.COMMA) {
Reported by PMD.
Line: 35
for (;;) {
Image image = imageDesc.deserialze(parser, Image.class, index);
images.add(image);
index++;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LBRACKET);
} else {
break;
}
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/decode/EishayDecode.java
5 issues
Line: 28
public void execute(Codec codec) throws Exception {
MediaContent content = codec.decodeObject(text, MediaContent.class);
if (content == null) {
throw new Exception();
}
}
}
Reported by PMD.
Line: 21
public void init(Codec codec) throws Exception {
this.text = codec.encode(EishayDecodeBytes.instance.getContent());
System.out.println(text);
}
@Override
public void execute(Codec codec) throws Exception {
MediaContent content = codec.decodeObject(text, MediaContent.class);
Reported by PMD.
Line: 10
public class EishayDecode extends BenchmarkCase {
private String text;
public EishayDecode(){
super("EishayDecode");
// JavaBeanMapping.getGlobalInstance().putDeserializer(Image.class, new ImageDeserializer());
Reported by PMD.
Line: 19
// JavaBeanMapping.getGlobalInstance().putDeserializer(Media.class, new MediaDeserializer());
}
public void init(Codec codec) throws Exception {
this.text = codec.encode(EishayDecodeBytes.instance.getContent());
System.out.println(text);
}
@Override
Reported by PMD.
Line: 20
}
public void init(Codec codec) throws Exception {
this.text = codec.encode(EishayDecodeBytes.instance.getContent());
System.out.println(text);
}
@Override
public void execute(Codec codec) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/decode/EishayDecodeBytes.java
5 issues
Line: 91
chars = (text + " ").toCharArray();
bytes = text.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException();
}
}
@Override
public void execute(Codec codec) throws Exception {
Reported by PMD.
Line: 19
import data.media.Media.Player;
import data.media.MediaContent;
public class EishayDecodeBytes extends BenchmarkCase {
public final static EishayDecodeBytes instance = new EishayDecodeBytes();
private final byte[] bytes;
private final char[] chars;
Reported by PMD.
Line: 30
private final MediaContent content;
public byte[] getBytes() {
return bytes;
}
public char[] getChars() {
return chars;
}
Reported by PMD.
Line: 34
}
public char[] getChars() {
return chars;
}
public String getText() {
return text;
}
Reported by PMD.
Line: 91
chars = (text + " ").toCharArray();
bytes = text.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException();
}
}
@Override
public void execute(Codec codec) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_short_public.java
5 issues
Line: 21
}
public static class VO {
private short id;
private String name;
public short getId() {
return id;
}
Reported by PMD.
Line: 24
private short id;
private String name;
public short getId() {
return id;
}
public void setId(short id) {
this.id = id;
Reported by PMD.
Line: 28
return id;
}
public void setId(short id) {
this.id = id;
}
public String getName() {
return name;
Reported by PMD.
Line: 11
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteAsArray_short_public extends TestCase {
public void test_0 () throws Exception {
VO vo = new VO();
vo.setId((short)123);
vo.setName("wenshao");
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Reported by PMD.
Line: 20
Assert.assertEquals("[123,\"wenshao\"]", text);
}
public static class VO {
private short id;
private String name;
public short getId() {
return id;
Reported by PMD.
src/test/java/com/alibaba/json/bvtVO/BigClass.java
5 issues
Line: 1
package com.alibaba.json.bvtVO;
public class BigClass {
public String field1 ;
public String field2 ;
public String field3 ;
public String field4 ;
public String field5 ;
public String field6 ;
Reported by PMD.
Line: 3
package com.alibaba.json.bvtVO;
public class BigClass {
public String field1 ;
public String field2 ;
public String field3 ;
public String field4 ;
public String field5 ;
public String field6 ;
Reported by PMD.
Line: 3
package com.alibaba.json.bvtVO;
public class BigClass {
public String field1 ;
public String field2 ;
public String field3 ;
public String field4 ;
public String field5 ;
public String field6 ;
Reported by PMD.
Line: 3
package com.alibaba.json.bvtVO;
public class BigClass {
public String field1 ;
public String field2 ;
public String field3 ;
public String field4 ;
public String field5 ;
public String field6 ;
Reported by PMD.
Line: 3
package com.alibaba.json.bvtVO;
public class BigClass {
public String field1 ;
public String field2 ;
public String field3 ;
public String field4 ;
public String field5 ;
public String field6 ;
Reported by PMD.