The following issues were found
src/test/java/com/alibaba/json/test/IntArrayFieldTest_primitive.java
7 issues
Line: 12
public class IntArrayFieldTest_primitive extends TestCase {
public void test_array() throws Exception {
Assert.assertEquals("[1]", JSON.toJSONString(new int[] { 1 }));
}
public void test_codec_null() throws Exception {
Reported by PMD.
Line: 17
}
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);
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
Reported by PMD.
Line: 31
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Assert.assertTrue(!mapping.isAsmEnable());
Reported by PMD.
Line: 47
private int[] value;
public int[] getValue() {
return value;
}
public void setValue(int[] value) {
this.value = value;
}
Reported by PMD.
Line: 50
return value;
}
public void setValue(int[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 50
return value;
}
public void setValue(int[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/test/jackson/JacksonTypeInfoTest.java
7 issues
Line: 18
A a = new B();
String str = mapper.writeValueAsString(a);
System.out.println(str);
Object x = mapper.readValue(str, A.class);
System.out.println(x.getClass());
}
Reported by PMD.
Line: 21
System.out.println(str);
Object x = mapper.readValue(str, A.class);
System.out.println(x.getClass());
}
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public static class A {
protected int a;
Reported by PMD.
Line: 12
* Created by wenshao on 02/04/2017.
*/
public class JacksonTypeInfoTest extends TestCase {
public void test_typeinfo() throws Exception {
ObjectMapper mapper = new ObjectMapper();
A a = new B();
String str = mapper.writeValueAsString(a);
Reported by PMD.
Line: 12
* Created by wenshao on 02/04/2017.
*/
public class JacksonTypeInfoTest extends TestCase {
public void test_typeinfo() throws Exception {
ObjectMapper mapper = new ObjectMapper();
A a = new B();
String str = mapper.writeValueAsString(a);
Reported by PMD.
Line: 21
System.out.println(str);
Object x = mapper.readValue(str, A.class);
System.out.println(x.getClass());
}
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public static class A {
protected int a;
Reported by PMD.
Line: 26
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public static class A {
protected int a;
public A() {
}
public A(int a) {
Reported by PMD.
Line: 3
package com.alibaba.json.test.jackson;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase;
/**
* Created by wenshao on 02/04/2017.
Reported by PMD.
src/test/java/data/media/MediaContent.java
7 issues
Line: 27
MediaContent that = (MediaContent) o;
if (images != null ? !images.equals(that.images) : that.images != null) return false;
if (media != null ? !media.equals(that.media) : that.media != null) return false;
return true;
}
@Override
Reported by PMD.
Line: 41
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
Reported by PMD.
Line: 42
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
}
Reported by PMD.
Line: 42
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
}
Reported by PMD.
Line: 43
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
}
Reported by PMD.
Line: 44
StringBuilder sb = new StringBuilder();
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
}
public void setMedia(Media media) {
Reported by PMD.
Line: 45
sb.append("[MediaContent: ");
sb.append("media=").append(media);
sb.append(", images=").append(images);
sb.append("]");
return sb.toString();
}
public void setMedia(Media media) {
this.media = media;
Reported by PMD.
src/test/java/com/alibaba/json/test/a/WhiteSpaceTest.java
6 issues
Line: 37
long endMillis = System.currentTimeMillis();
long millis = endMillis - startMillis;
System.out.println("millis : " + millis + ", count " + count);
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.util.IOUtils;
public class WhiteSpaceTest {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 3; ++i) {
perf();
}
//ch < IOUtils.whitespaceFlags.length && IOUtils.whitespaceFlags[ch]
Reported by PMD.
Line: 6
import com.alibaba.fastjson.util.IOUtils;
public class WhiteSpaceTest {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 3; ++i) {
perf();
}
//ch < IOUtils.whitespaceFlags.length && IOUtils.whitespaceFlags[ch]
}
Reported by PMD.
Line: 3
package com.alibaba.json.test.a;
import com.alibaba.fastjson.util.IOUtils;
public class WhiteSpaceTest {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 3; ++i) {
perf();
}
Reported by PMD.
Line: 14
}
protected static void perf() {
int count = 0;
long startMillis = System.currentTimeMillis();
for (int i = 0; i < 1000 * 200; ++i) {
for (char ch = 0; ch < 10000; ++ch) {
Reported by PMD.
Line: 24
// boolean whitespace = c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\f' || c == '\b';
boolean whitespace = ch <= ' ' && (ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t' || ch == '\f' || ch == '\b');
if (whitespace) {
count++;
}
// if (ch < IOUtils.whitespaceFlags.length && IOUtils.whitespaceFlags[ch]) {
// count++;
// }
// if (c <= ' ' && (c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\f' || c == '\b')) {
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/FastjsonCodec.java
6 issues
Line: 17
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
public String getName() {
return "fastjson";
}
Reported by PMD.
Line: 14
public class FastjsonCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
Reported by PMD.
Line: 14
public class FastjsonCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
Reported by PMD.
Line: 30
return parser.parseObject(clazz);
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Reported by PMD.
Line: 50
// private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);
public String encode(Object object) throws Exception {
return JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
Reported by PMD.
Line: 55
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
return (T) JSON.parseObject(input, clazz, Feature.DisableCircularReferenceDetect);
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/FastjsonGenCodec.java
6 issues
Line: 82
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
Reported by PMD.
Line: 23
public class FastjsonGenCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonGenCodec() {
config.putDeserializer(Image.class, new ImageGenDecoder(config, Image.class));
config.putDeserializer(Media.class, new MediaGenDecoder(config, Media.class));
config.putDeserializer(MediaContent.class, new MediaContentGenDecoder(config, MediaContent.class));
Reported by PMD.
Line: 23
public class FastjsonGenCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonGenCodec() {
config.putDeserializer(Image.class, new ImageGenDecoder(config, Image.class));
config.putDeserializer(Media.class, new MediaGenDecoder(config, Media.class));
config.putDeserializer(MediaContent.class, new MediaContentGenDecoder(config, MediaContent.class));
Reported by PMD.
Line: 41
return parser.parseObject(clazz);
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Reported by PMD.
Line: 61
// private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);
public String encode(Object object) throws Exception {
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.DisableCircularReferenceDetect, true);
// out.config(SerializerFeature.DisableCheckSpecialChar, true);
JSONSerializer serializer = new JSONSerializer(out);
Reported by PMD.
Line: 77
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
return (T) JSON.parseObject(input, clazz, Feature.DisableCircularReferenceDetect);
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/basic/FloatBenchmark_arrayMapping.java
6 issues
Line: 35
JSON.parseObject(json, Model.class, Feature.SupportArrayToBean);
}
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; ++i) {
Reported by PMD.
Line: 44
JSON.parseObject(json2, Model.class, Feature.SupportArrayToBean);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public float v1;
public float v2;
Reported by PMD.
Line: 9
/**
* Created by wenshao on 04/08/2017.
*/
public class FloatBenchmark_arrayMapping {
static String json = "[0.012671709,0.6042485,0.13231707,0.80090785,0.6192943]";
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
Reported by PMD.
Line: 13
static String json = "[0.012671709,0.6042485,0.13231707,0.80090785,0.6192943]";
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
Reported by PMD.
Line: 14
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
Line: 14
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
src/test/java/com/alibaba/json/test/jackson/JacksonTest.java
6 issues
Line: 24
model.id = 1001;
ObjectMapper mapper = new ObjectMapper();
String text = mapper.writeValueAsString(model);
System.out.println(text);
}
public static class Model {
public int id;
}
Reported by PMD.
Line: 12
public class JacksonTest extends TestCase {
public void test_0() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.readValue("{a:3}", Map.class);
}
Reported by PMD.
Line: 12
public class JacksonTest extends TestCase {
public void test_0() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.readValue("{a:3}", Map.class);
}
Reported by PMD.
Line: 19
mapper.readValue("{a:3}", Map.class);
}
public void test_1() throws Exception {
Model model = new Model();
model.id = 1001;
ObjectMapper mapper = new ObjectMapper();
String text = mapper.writeValueAsString(model);
System.out.println(text);
Reported by PMD.
Line: 19
mapper.readValue("{a:3}", Map.class);
}
public void test_1() throws Exception {
Model model = new Model();
model.id = 1001;
ObjectMapper mapper = new ObjectMapper();
String text = mapper.writeValueAsString(model);
System.out.println(text);
Reported by PMD.
Line: 28
}
public static class Model {
public int id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/FastjsonArrayMappingCodec.java
6 issues
Line: 17
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonArrayMappingCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
public String getName() {
return "fastjson-BeanToArray";
}
Reported by PMD.
Line: 14
public class FastjsonArrayMappingCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonArrayMappingCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
Reported by PMD.
Line: 14
public class FastjsonArrayMappingCodec implements Codec {
private ParserConfig config = ParserConfig.getGlobalInstance();
public FastjsonArrayMappingCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
Reported by PMD.
Line: 28
return JSON.parseObject(text, clazz, Feature.DisableCircularReferenceDetect, Feature.SupportArrayToBean);
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Reported by PMD.
Line: 44
// private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);
public String encode(Object object) throws Exception {
return JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.BeanToArray);
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
Reported by PMD.
Line: 49
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
return (T) JSON.parseObject(input, clazz, Feature.DisableCircularReferenceDetect, Feature.SupportArrayToBean);
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/FastjsonSCodec.java
6 issues
Line: 78
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
Reported by PMD.
Line: 19
public class FastjsonSCodec implements Codec {
public FastjsonSCodec(){
System.out.println("fastjson-" + JSON.VERSION);
}
public String getName() {
return "fastjsonS";
}
Reported by PMD.
Line: 33
return parser.parseObject(clazz);
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
ParserConfig config = new ParserConfig();
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Reported by PMD.
Line: 56
// private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);
public String encode(Object object) throws Exception {
SerializeConfig config = new SerializeConfig();
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.DisableCircularReferenceDetect, true);
// out.config(SerializerFeature.DisableCheckSpecialChar, true);
Reported by PMD.
Line: 73
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
return (T) JSON.parseObject(input, clazz, Feature.DisableCircularReferenceDetect);
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
Reported by PMD.
Line: 12
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class FastjsonSCodec implements Codec {
Reported by PMD.