The following issues were found
src/test/java/com/alibaba/fastjson/deserializer/issue3050/TestIssue3050.java
4 issues
Line: 21
public void testIssue3050() {
String jsonStr = "{\"name\":5, \"address\":\"beijing\", \"id\":\"100\", \"age\":10}";
Person person = JSON.parseObject(jsonStr, Person.class, Feature.InitStringFieldAsEmpty);
Assert.assertEquals("5", person.getName());
Assert.assertEquals("beijing", person.getAddress());
Assert.assertEquals("100", person.getId());
Assert.assertEquals(10, person.getAge());
}
Reported by PMD.
Line: 22
String jsonStr = "{\"name\":5, \"address\":\"beijing\", \"id\":\"100\", \"age\":10}";
Person person = JSON.parseObject(jsonStr, Person.class, Feature.InitStringFieldAsEmpty);
Assert.assertEquals("5", person.getName());
Assert.assertEquals("beijing", person.getAddress());
Assert.assertEquals("100", person.getId());
Assert.assertEquals(10, person.getAge());
}
}
Reported by PMD.
Line: 23
Person person = JSON.parseObject(jsonStr, Person.class, Feature.InitStringFieldAsEmpty);
Assert.assertEquals("5", person.getName());
Assert.assertEquals("beijing", person.getAddress());
Assert.assertEquals("100", person.getId());
Assert.assertEquals(10, person.getAge());
}
}
Reported by PMD.
Line: 24
Assert.assertEquals("5", person.getName());
Assert.assertEquals("beijing", person.getAddress());
Assert.assertEquals("100", person.getId());
Assert.assertEquals(10, person.getAge());
}
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/PropertyProcessableDeserializer.java
4 issues
Line: 13
* Created by wenshao on 15/07/2017.
*/
public class PropertyProcessableDeserializer implements ObjectDeserializer {
public final Class<PropertyProcessable> type;
public PropertyProcessableDeserializer(Class<PropertyProcessable> type) {
this.type = type;
}
Reported by PMD.
Line: 23
PropertyProcessable processable;
try {
processable = this.type.newInstance();
} catch (Exception e) {
throw new JSONException("craete instance error");
}
Object object =parser.parse(processable, fieldName);
Reported by PMD.
Line: 24
try {
processable = this.type.newInstance();
} catch (Exception e) {
throw new JSONException("craete instance error");
}
Object object =parser.parse(processable, fieldName);
return (T) object;
Reported by PMD.
Line: 22
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
PropertyProcessable processable;
try {
processable = this.type.newInstance();
} catch (Exception e) {
throw new JSONException("craete instance error");
}
Object object =parser.parse(processable, fieldName);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestDeprecate.java
4 issues
Line: 9
public class TestDeprecate extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setId(123);
String text = JSON.toJSONString(vo);
}
Reported by PMD.
Line: 9
public class TestDeprecate extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setId(123);
String text = JSON.toJSONString(vo);
}
Reported by PMD.
Line: 13
VO vo = new VO();
vo.setId(123);
String text = JSON.toJSONString(vo);
}
public static class VO {
private int id;
Reported by PMD.
Line: 13
VO vo = new VO();
vo.setId(123);
String text = JSON.toJSONString(vo);
}
public static class VO {
private int id;
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/JSONToken.java
4 issues
Line: 21
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONToken {
//
public final static int ERROR = 1;
//
public final static int LITERAL_INT = 2;
Reported by PMD.
Line: 21
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONToken {
//
public final static int ERROR = 1;
//
public final static int LITERAL_INT = 2;
Reported by PMD.
Line: 73
public final static int DOT = 25;
public final static int HEX = 26;
public static String name(int value) {
switch (value) {
case ERROR:
return "error";
case LITERAL_INT:
return "int";
Reported by PMD.
Line: 73
public final static int DOT = 25;
public final static int HEX = 26;
public static String name(int value) {
switch (value) {
case ERROR:
return "error";
case LITERAL_INT:
return "int";
Reported by PMD.
src/test/java/com/alibaba/fastjson/serializer/issue3479/TestIssue3479.java
4 issues
Line: 69
dog.dogName = "dog1001";
String text = JSON.toJSONString(dog, SerializerFeature.WriteClassName);
System.out.println(text);
Dog dog2 = (Dog) JSON.parseObject(text, Animal.class);
System.out.println(dog2);
}
Reported by PMD.
Line: 73
Dog dog2 = (Dog) JSON.parseObject(text, Animal.class);
System.out.println(dog2);
}
}
Reported by PMD.
Line: 7
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class TestIssue3479 {
@JSONType(seeAlso = {Dog.class, Cat.class}, typeKey = "typeKey")
public static abstract class Animal {
private String typeKey;
Reported by PMD.
Line: 10
public class TestIssue3479 {
@JSONType(seeAlso = {Dog.class, Cat.class}, typeKey = "typeKey")
public static abstract class Animal {
private String typeKey;
public String getTypeKey() {
return typeKey;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_smoothrat7.java
4 issues
Line: 20
map.put("self", map);
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"java.util.HashMap\",\"self\":{\"$ref\":\"@\"}}",
text);
Map<String, Object> entity2 = (Map<String, Object>) JSON.parse(text);
Assert.assertEquals(map.getClass(), entity2.getClass());
Reported by PMD.
Line: 14
public class Bug_for_smoothrat7 extends TestCase {
@SuppressWarnings("unchecked")
public void test_self() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("self", map);
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 25
text);
Map<String, Object> entity2 = (Map<String, Object>) JSON.parse(text);
Assert.assertEquals(map.getClass(), entity2.getClass());
Assert.assertSame(entity2, entity2.get("self"));
}
}
Reported by PMD.
Line: 26
Map<String, Object> entity2 = (Map<String, Object>) JSON.parse(text);
Assert.assertEquals(map.getClass(), entity2.getClass());
Assert.assertSame(entity2, entity2.get("self"));
}
}
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectA.java
4 issues
Line: 1
package com.alibaba.fastjson.deserializer.issues3796.bean;
public class ObjectA {
private static final String NULL = "NULL";
private String a = NULL;
Reported by PMD.
Line: 5
public class ObjectA {
private static final String NULL = "NULL";
private String a = NULL;
Reported by PMD.
Line: 5
public class ObjectA {
private static final String NULL = "NULL";
private String a = NULL;
Reported by PMD.
Line: 7
public class ObjectA {
private static final String NULL = "NULL";
private String a = NULL;
private String b = NULL;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_jared1.java
4 issues
Line: 17
String text = JSON.toJSONString(user);
System.out.println(text);
JSON.parseObject(text, User.class);
}
public static class User implements Serializable {
Reported by PMD.
Line: 12
import com.alibaba.fastjson.JSON;
public class Bug_for_jared1 extends TestCase {
public void test_for_jared1() throws Exception {
User user = new User();
String text = JSON.toJSONString(user);
System.out.println(text);
Reported by PMD.
Line: 12
import com.alibaba.fastjson.JSON;
public class Bug_for_jared1 extends TestCase {
public void test_for_jared1() throws Exception {
User user = new User();
String text = JSON.toJSONString(user);
System.out.println(text);
Reported by PMD.
Line: 22
JSON.parseObject(text, User.class);
}
public static class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/javabean/ConvertDO.java
4 issues
Line: 24
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ConvertDO implements Serializable {
private static final long serialVersionUID = 3987648902475498726L;
private int inta;
private Integer intb;
Reported by PMD.
Line: 10
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
Reported by PMD.
Line: 11
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
Reported by PMD.
Line: 12
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest_getBigInteger.java
4 issues
Line: 13
public class JSONObjectTest_getBigInteger extends TestCase {
public void test_get_float() throws Exception {
JSONObject obj = new JSONObject();
obj.put("value", 123.45F);
Assert.assertTrue(123.45F == ((Float) obj.get("value")).floatValue());
Assert.assertEquals(new BigInteger("123"), obj.getBigInteger("value"));
}
Reported by PMD.
Line: 15
public void test_get_float() throws Exception {
JSONObject obj = new JSONObject();
obj.put("value", 123.45F);
Assert.assertTrue(123.45F == ((Float) obj.get("value")).floatValue());
Assert.assertEquals(new BigInteger("123"), obj.getBigInteger("value"));
}
public void test_get_double() throws Exception {
Reported by PMD.
Line: 20
Assert.assertEquals(new BigInteger("123"), obj.getBigInteger("value"));
}
public void test_get_double() throws Exception {
JSONObject obj = new JSONObject();
obj.put("value", 123.45D);
Assert.assertTrue(123.45D == ((Double) obj.get("value")).doubleValue());
Assert.assertEquals(new BigInteger("123"), obj.getBigInteger("value"));
}
Reported by PMD.
Line: 27
Assert.assertEquals(new BigInteger("123"), obj.getBigInteger("value"));
}
public void test_get_empty() throws Exception {
JSONObject obj = new JSONObject();
obj.put("value", "");
Assert.assertEquals("", obj.get("value"));
Assert.assertNull(obj.getBigInteger("value"));
}
Reported by PMD.