The following issues were found
src/main/java/com/alibaba/fastjson/util/IOUtils.java
142 issues
Line: 213
return 19;
}
public static void getChars(long i, int index, char[] buf) {
long q;
int r;
int charPos = index;
char sign = 0;
Reported by PMD.
Line: 213
return 19;
}
public static void getChars(long i, int index, char[] buf) {
long q;
int r;
int charPos = index;
char sign = 0;
Reported by PMD.
Line: 265
* buffer backwards starting with the least significant digit at the specified index (exclusive), and working
* backwards from there. Will fail if i == Integer.MIN_VALUE
*/
public static void getChars(int i, int index, char[] buf) {
int q, r, p = index;
char sign = 0;
if (i < 0) {
sign = '-';
Reported by PMD.
Line: 265
* buffer backwards starting with the least significant digit at the specified index (exclusive), and working
* backwards from there. Will fail if i == Integer.MIN_VALUE
*/
public static void getChars(int i, int index, char[] buf) {
int q, r, p = index;
char sign = 0;
if (i < 0) {
sign = '-';
Reported by PMD.
Line: 265
* buffer backwards starting with the least significant digit at the specified index (exclusive), and working
* backwards from there. Will fail if i == Integer.MIN_VALUE
*/
public static void getChars(int i, int index, char[] buf) {
int q, r, p = index;
char sign = 0;
if (i < 0) {
sign = '-';
Reported by PMD.
Line: 585
return dArr;
}
public static int encodeUTF8(char[] chars, int offset, int len, byte[] bytes) {
int sl = offset + len;
int dp = 0;
int dlASCII = dp + Math.min(len, bytes.length);
// ASCII only optimized loop
Reported by PMD.
Line: 585
return dArr;
}
public static int encodeUTF8(char[] chars, int offset, int len, byte[] bytes) {
int sl = offset + len;
int dp = 0;
int dlASCII = dp + Math.min(len, bytes.length);
// ASCII only optimized loop
Reported by PMD.
Line: 585
return dArr;
}
public static int encodeUTF8(char[] chars, int offset, int len, byte[] bytes) {
int sl = offset + len;
int dp = 0;
int dlASCII = dp + Math.min(len, bytes.length);
// ASCII only optimized loop
Reported by PMD.
Line: 654
/**
* @deprecated
*/
public static int decodeUTF8(byte[] sa, int sp, int len, char[] da) {
final int sl = sp + len;
int dp = 0;
int dlASCII = Math.min(len, da.length);
// ASCII only optimized loop
Reported by PMD.
Line: 654
/**
* @deprecated
*/
public static int decodeUTF8(byte[] sa, int sp, int len, char[] da) {
final int sl = sp + len;
int dp = 0;
int dlASCII = Math.min(len, da.length);
// ASCII only optimized loop
Reported by PMD.
src/main/java/com/alibaba/fastjson/util/FieldInfo.java
124 issues
Line: 86
fieldAccess = false;
}
name_chars = genFieldNameChars();
if (field != null) {
TypeUtils.setAccessible(field);
}
Reported by PMD.
Line: 168
}
String format = null;
JSONField annotation = getAnnotation();
nameHashCode = nameHashCode64(name, annotation);
boolean jsonDirect = false;
if (annotation != null) {
Reported by PMD.
Line: 189
}
this.format = format;
name_chars = genFieldNameChars();
if (method != null) {
TypeUtils.setAccessible(method);
}
Reported by PMD.
Line: 58
Class<?> fieldClass, //
Type fieldType, //
Field field, //
int ordinal, //
int serialzeFeatures, //
int parserFeatures){
if (ordinal < 0) {
ordinal = 0;
}
Reported by PMD.
Line: 119
fieldAnnotation, methodAnnotation, label, null);
}
public FieldInfo(String name, //
Method method, //
Field field, //
Class<?> clazz, //
Type type, //
int ordinal, //
Reported by PMD.
Line: 124
Field field, //
Class<?> clazz, //
Type type, //
int ordinal, //
int serialzeFeatures, //
int parserFeatures, //
JSONField fieldAnnotation, //
JSONField methodAnnotation, //
String label,
Reported by PMD.
Line: 296
return getFieldType(clazz, type, fieldType, null);
}
public static Type getFieldType(final Class<?> clazz, final Type type, Type fieldType, Map<TypeVariable, Type> genericInfo) {
if (clazz == null || type == null) {
return fieldType;
}
if (fieldType instanceof GenericArrayType) {
Reported by PMD.
Line: 296
return getFieldType(clazz, type, fieldType, null);
}
public static Type getFieldType(final Class<?> clazz, final Type type, Type fieldType, Map<TypeVariable, Type> genericInfo) {
if (clazz == null || type == null) {
return fieldType;
}
if (fieldType instanceof GenericArrayType) {
Reported by PMD.
Line: 20
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.annotation.JSONField;
public class FieldInfo implements Comparable<FieldInfo> {
public final String name;
public final Method method;
public final Field field;
Reported by PMD.
Line: 20
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.annotation.JSONField;
public class FieldInfo implements Comparable<FieldInfo> {
public final String name;
public final Method method;
public final Field field;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONFieldDefaultValueTest.java
119 issues
Line: 65
@JSONField(defaultValue = "888") //shouldn't work
private int anInt;
@JSONField(defaultValue = "88") //shouldn't work
private short aShort;
@JSONField(defaultValue = "J") //shouldn't work
private char aChar;
@JSONField(defaultValue = "8") //shouldn't work
private byte aByte;
@JSONField(defaultValue = "8888") //shouldn't work
Reported by PMD.
Line: 144
this.anInt = anInt;
}
public short getaShort() {
return aShort;
}
public void setaShort(short aShort) {
this.aShort = aShort;
Reported by PMD.
Line: 148
return aShort;
}
public void setaShort(short aShort) {
this.aShort = aShort;
}
public char getaChar() {
return aChar;
Reported by PMD.
Line: 11
public void test_default_value() throws Exception {
Model m = new Model();
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
assertEquals(false, m2.getaBoolean());
assertEquals(true, m2.getaBoolean2().booleanValue());
assertEquals(0, m2.getAnInt());
Reported by PMD.
Line: 35
public void test_not_null() throws Exception {
Model m = new Model("test", true, 888, (short)88, 'J', (byte)8, 8888L, 8.8F, 88.88, false, 999, (short)99, 'C', (byte)9, 9999L, 9.9F, 99.99);
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("test", m2.getString());
assertEquals(true, m2.getaBoolean());
assertEquals(false, m2.getaBoolean2().booleanValue());
assertEquals(888, m2.getAnInt());
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class JSONFieldDefaultValueTest extends TestCase {
public void test_default_value() throws Exception {
Model m = new Model();
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class JSONFieldDefaultValueTest extends TestCase {
public void test_default_value() throws Exception {
Model m = new Model();
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
Reported by PMD.
Line: 13
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
assertEquals(false, m2.getaBoolean());
assertEquals(true, m2.getaBoolean2().booleanValue());
assertEquals(0, m2.getAnInt());
assertEquals(888, m2.getInteger().intValue());
assertEquals(0, m2.getaShort());
Reported by PMD.
Line: 13
String s = JSON.toJSONString(m);
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
assertEquals(false, m2.getaBoolean());
assertEquals(true, m2.getaBoolean2().booleanValue());
assertEquals(0, m2.getAnInt());
assertEquals(888, m2.getInteger().intValue());
assertEquals(0, m2.getaShort());
Reported by PMD.
Line: 14
System.out.println(s);
Model m2 = JSON.parseObject(s, Model.class);
assertEquals("string", m2.getString());
assertEquals(false, m2.getaBoolean());
assertEquals(true, m2.getaBoolean2().booleanValue());
assertEquals(0, m2.getAnInt());
assertEquals(888, m2.getInteger().intValue());
assertEquals(0, m2.getaShort());
assertEquals(88, m2.getaShort2().shortValue());
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/JavaBeanSerializer.java
117 issues
Line: 101
getters = new FieldSerializer[beanInfo.fields.length];
boolean hashNotMatch = false;
for (int i = 0; i < getters.length; ++i) {
FieldSerializer fieldSerializer = getFieldSerializer(beanInfo.fields[i].name);
if (fieldSerializer == null) {
hashNotMatch = true;
break;
}
getters[i] = fieldSerializer;
Reported by PMD.
Line: 547
}
}
protected void writeClassName(JSONSerializer serializer, String typeKey, Object object) {
if (typeKey == null) {
typeKey = serializer.config.typeKey;
}
serializer.out.writeFieldName(typeKey, false);
String typeName = this.beanInfo.typeName;
Reported by PMD.
Line: 815
}
protected char writeBefore(JSONSerializer jsonBeanDeser, //
Object object, char seperator) {
if (jsonBeanDeser.beforeFilters != null) {
for (BeforeFilter beforeFilter : jsonBeanDeser.beforeFilters) {
seperator = beforeFilter.writeBefore(jsonBeanDeser, object, seperator);
}
Reported by PMD.
Line: 815
}
protected char writeBefore(JSONSerializer jsonBeanDeser, //
Object object, char seperator) {
if (jsonBeanDeser.beforeFilters != null) {
for (BeforeFilter beforeFilter : jsonBeanDeser.beforeFilters) {
seperator = beforeFilter.writeBefore(jsonBeanDeser, object, seperator);
}
Reported by PMD.
Line: 833
}
protected char writeAfter(JSONSerializer jsonBeanDeser, //
Object object, char seperator) {
if (jsonBeanDeser.afterFilters != null) {
for (AfterFilter afterFilter : jsonBeanDeser.afterFilters) {
seperator = afterFilter.writeAfter(jsonBeanDeser, object, seperator);
}
}
Reported by PMD.
Line: 833
}
protected char writeAfter(JSONSerializer jsonBeanDeser, //
Object object, char seperator) {
if (jsonBeanDeser.afterFilters != null) {
for (AfterFilter afterFilter : jsonBeanDeser.afterFilters) {
seperator = afterFilter.writeAfter(jsonBeanDeser, object, seperator);
}
}
Reported by PMD.
Line: 45
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JavaBeanSerializer extends SerializeFilterable implements ObjectSerializer {
// serializers
protected final FieldSerializer[] getters;
protected final FieldSerializer[] sortedGetters;
protected final SerializeBeanInfo beanInfo;
Reported by PMD.
Line: 45
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JavaBeanSerializer extends SerializeFilterable implements ObjectSerializer {
// serializers
protected final FieldSerializer[] getters;
protected final FieldSerializer[] sortedGetters;
protected final SerializeBeanInfo beanInfo;
Reported by PMD.
Line: 45
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JavaBeanSerializer extends SerializeFilterable implements ObjectSerializer {
// serializers
protected final FieldSerializer[] getters;
protected final FieldSerializer[] sortedGetters;
protected final SerializeBeanInfo beanInfo;
Reported by PMD.
Line: 45
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JavaBeanSerializer extends SerializeFilterable implements ObjectSerializer {
// serializers
protected final FieldSerializer[] getters;
protected final FieldSerializer[] sortedGetters;
protected final SerializeBeanInfo beanInfo;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateFieldTest9.java
111 issues
Line: 14
import junit.framework.TestCase;
public class DateFieldTest9 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
Reported by PMD.
Line: 16
public class DateFieldTest9 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_tw() throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_tw() throws Exception {
Entity vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", Entity.class);
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date);
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Reported by PMD.
Line: 25
Entity vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", Entity.class);
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date);
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Reported by PMD.
Line: 26
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date);
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Reported by PMD.
Line: 27
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date);
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Assert.assertEquals(0, calendar.get(Calendar.MILLISECOND));
Reported by PMD.
Line: 28
calendar.setTime(vo.date);
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Assert.assertEquals(0, calendar.get(Calendar.MILLISECOND));
}
Reported by PMD.
Line: 29
Assert.assertEquals(2016, calendar.get(Calendar.YEAR));
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Assert.assertEquals(0, calendar.get(Calendar.MILLISECOND));
}
Reported by PMD.
Line: 30
Assert.assertEquals(4, calendar.get(Calendar.MONTH));
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Assert.assertEquals(0, calendar.get(Calendar.MILLISECOND));
}
public void test_cn() throws Exception {
Reported by PMD.
Line: 31
Assert.assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, calendar.get(Calendar.MINUTE));
Assert.assertEquals(0, calendar.get(Calendar.SECOND));
Assert.assertEquals(0, calendar.get(Calendar.MILLISECOND));
}
public void test_cn() throws Exception {
Entity vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", Entity.class);
Reported by PMD.
src/test/java/com/alibaba/json/test/performance/JacksonGroupParser.java
111 issues
Line: 50
} else if ("companies" == name) {
parseCompany(group.getCompanies());
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
Reported by PMD.
Line: 87
} else if ("rootDepartment" == name) {
company.setRootDepartment(parseDepartment());
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
Reported by PMD.
Line: 124
} else if ("members" == name) {
parseEmployee(company.getMembers());
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
Reported by PMD.
Line: 167
} else if ("badboy" == name) {
emp.setBadboy(acceptBoolean(tok));
} else {
throw new RuntimeException("not match property : " + name);
}
}
}
accept(JsonToken.END_OBJECT);
Reported by PMD.
Line: 18
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
public class JacksonGroupParser {
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
Reported by PMD.
Line: 18
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
public class JacksonGroupParser {
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
Reported by PMD.
Line: 18
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
public class JacksonGroupParser {
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
Reported by PMD.
Line: 20
public class JacksonGroupParser {
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
parser.nextToken(); // move to the start of the
}
Reported by PMD.
Line: 20
public class JacksonGroupParser {
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
parser.nextToken(); // move to the start of the
}
Reported by PMD.
Line: 22
private JsonParser parser;
public JacksonGroupParser(JsonParser parser) throws Exception{
this.parser = parser;
parser.nextToken(); // move to the start of the
}
public Group parseGroup() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/mock/testcase/FastJsonHttpMessageConverterJSONPCaseTest.java
106 issues
Line: 37
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration
public class FastJsonHttpMessageConverterJSONPCaseTest {
private static final MediaType APPLICATION_JAVASCRIPT = new MediaType("application", "javascript");
@Autowired
private WebApplicationContext wac;
Reported by PMD.
Line: 41
private static final MediaType APPLICATION_JAVASCRIPT = new MediaType("application", "javascript");
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@ComponentScan(basePackages = "com.alibaba.json.bvt.support.spring.mock.controller")
@EnableWebMvc
Reported by PMD.
Line: 43
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@ComponentScan(basePackages = "com.alibaba.json.bvt.support.spring.mock.controller")
@EnableWebMvc
@Configuration
protected static class Config extends WebMvcConfigurerAdapter {
Reported by PMD.
Line: 70
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) //
.addFilter(new CharacterEncodingFilter("UTF-8", true)) // 设置服务器端返回的字符集为:UTF-8
.build();
}
@Test
public void isInjectComponent() {
Reported by PMD.
Line: 75
}
@Test
public void isInjectComponent() {
wac.getBean(JSONPResponseBodyAdvice.class);
wac.getBean(FastJsonViewResponseBodyAdvice.class);
}
@Test
Reported by PMD.
Line: 81
}
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/jsonp-fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status().isOk()).andDo(print());
}
Reported by PMD.
Line: 82
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/jsonp-fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status().isOk()).andDo(print());
}
@Test
Reported by PMD.
Line: 82
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/jsonp-fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status().isOk()).andDo(print());
}
@Test
Reported by PMD.
Line: 83
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/jsonp-fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status().isOk()).andDo(print());
}
@Test
public void test1_2() throws Exception {
Reported by PMD.
Line: 83
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/jsonp-fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status().isOk()).andDo(print());
}
@Test
public void test1_2() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/hsf/HSFJSONUtilsTest_1.java
103 issues
Line: 10
import java.lang.reflect.Method;
import java.util.List;
public class HSFJSONUtilsTest_1 extends TestCase {
private Method method_f2;
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
Reported by PMD.
Line: 11
import java.util.List;
public class HSFJSONUtilsTest_1 extends TestCase {
private Method method_f2;
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
Reported by PMD.
Line: 12
public class HSFJSONUtilsTest_1 extends TestCase {
private Method method_f2;
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
protected void setUp() throws Exception {
Reported by PMD.
Line: 13
public class HSFJSONUtilsTest_1 extends TestCase {
private Method method_f2;
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
protected void setUp() throws Exception {
method_f2 = Service.class.getMethod("f2", String.class, Model.class);
Reported by PMD.
Line: 14
private Method method_f2;
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
protected void setUp() throws Exception {
method_f2 = Service.class.getMethod("f2", String.class, Model.class);
method_f3 = Service.class.getMethod("f3", String.class, List.class);
Reported by PMD.
Line: 15
private Method method_f3;
private Method method_f4;
private Method method_f5;
private MethodLocator methodLocator;
protected void setUp() throws Exception {
method_f2 = Service.class.getMethod("f2", String.class, Model.class);
method_f3 = Service.class.getMethod("f3", String.class, List.class);
method_f4 = Service.class.getMethod("f3", String.class, Model[].class);
Reported by PMD.
Line: 17
private Method method_f5;
private MethodLocator methodLocator;
protected void setUp() throws Exception {
method_f2 = Service.class.getMethod("f2", String.class, Model.class);
method_f3 = Service.class.getMethod("f3", String.class, List.class);
method_f4 = Service.class.getMethod("f3", String.class, Model[].class);
method_f5 = Service.class.getMethod("f3", int.class, long.class);
Reported by PMD.
Line: 29
return null;
}
if (types[0].equals("int")) {
return method_f5;
}
if (types[1].equals("java.util.List")) {
return method_f3;
Reported by PMD.
Line: 33
return method_f5;
}
if (types[1].equals("java.util.List")) {
return method_f3;
}
if (types[1].equals("com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_0$Model[]")) {
return method_f4;
Reported by PMD.
Line: 37
return method_f3;
}
if (types[1].equals("com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_0$Model[]")) {
return method_f4;
}
return method_f2;
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/MapDeserializer.java
99 issues
Line: 16
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask;
public class MapDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public static MapDeserializer instance = new MapDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, String format, int features)
{
Reported by PMD.
Line: 16
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask;
public class MapDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public static MapDeserializer instance = new MapDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, String format, int features)
{
Reported by PMD.
Line: 16
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask;
public class MapDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public static MapDeserializer instance = new MapDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, String format, int features)
{
Reported by PMD.
Line: 16
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask;
public class MapDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public static MapDeserializer instance = new MapDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName, String format, int features)
{
Reported by PMD.
Line: 27
}
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
boolean unmodifiableMap = type instanceof Class
Reported by PMD.
Line: 35
boolean unmodifiableMap = type instanceof Class
&& "java.util.Collections$UnmodifiableMap".equals(((Class) type).getName());
Map<Object, Object> map = (lexer.getFeatures() & Feature.OrderedField.mask) != 0
? createMap(type, lexer.getFeatures())
: createMap(type);
ParseContext context = parser.getContext();
Reported by PMD.
Line: 36
&& "java.util.Collections$UnmodifiableMap".equals(((Class) type).getName());
Map<Object, Object> map = (lexer.getFeatures() & Feature.OrderedField.mask) != 0
? createMap(type, lexer.getFeatures())
: createMap(type);
ParseContext context = parser.getContext();
try {
Reported by PMD.
Line: 61
protected Object deserialze(DefaultJSONParser parser, Type type, Object fieldName, Map map, int features) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type keyType = parameterizedType.getActualTypeArguments()[0];
Type valueType = null;
if(map.getClass().getName().equals("org.springframework.util.LinkedMultiValueMap")){
valueType = List.class;
}else{
valueType = parameterizedType.getActualTypeArguments()[1];
Reported by PMD.
Line: 62
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type keyType = parameterizedType.getActualTypeArguments()[0];
Type valueType = null;
if(map.getClass().getName().equals("org.springframework.util.LinkedMultiValueMap")){
valueType = List.class;
}else{
valueType = parameterizedType.getActualTypeArguments()[1];
}
Reported by PMD.
Line: 63
ParameterizedType parameterizedType = (ParameterizedType) type;
Type keyType = parameterizedType.getActualTypeArguments()[0];
Type valueType = null;
if(map.getClass().getName().equals("org.springframework.util.LinkedMultiValueMap")){
valueType = List.class;
}else{
valueType = parameterizedType.getActualTypeArguments()[1];
}
if (String.class == keyType) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultExtJSONParserTest.java
97 issues
Line: 62
String jsonString = JSON.toJSONString(user);
System.out.println(jsonString);
JSON.parseObject(jsonString);
DefaultJSONParser parser = new DefaultJSONParser(jsonString);
User user1 = new User();
Reported by PMD.
Line: 51
import junit.framework.TestCase;
public class DefaultExtJSONParserTest extends TestCase {
public void test_parseObject() {
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
User user = new User();
user.setName("校长");
Reported by PMD.
Line: 51
import junit.framework.TestCase;
public class DefaultExtJSONParserTest extends TestCase {
public void test_parseObject() {
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
User user = new User();
user.setName("校长");
Reported by PMD.
Line: 51
import junit.framework.TestCase;
public class DefaultExtJSONParserTest extends TestCase {
public void test_parseObject() {
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
User user = new User();
user.setName("校长");
Reported by PMD.
Line: 53
public class DefaultExtJSONParserTest extends TestCase {
public void test_parseObject() {
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
User user = new User();
user.setName("校长");
user.setAge(3);
user.setSalary(new BigDecimal("123456789.0123"));
Reported by PMD.
Line: 75
Assert.assertEquals(user.getSalary(), user1.getSalary());
}
public void testCastCalendar() throws Exception {
Calendar c = Calendar.getInstance();
Date d = TypeUtils.castToDate(c);
Assert.assertEquals(c.getTime(), d);
}
Reported by PMD.
Line: 78
public void testCastCalendar() throws Exception {
Calendar c = Calendar.getInstance();
Date d = TypeUtils.castToDate(c);
Assert.assertEquals(c.getTime(), d);
}
public void testCast() throws Exception {
new TypeUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Reported by PMD.
Line: 78
public void testCastCalendar() throws Exception {
Calendar c = Calendar.getInstance();
Date d = TypeUtils.castToDate(c);
Assert.assertEquals(c.getTime(), d);
}
public void testCast() throws Exception {
new TypeUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Reported by PMD.
Line: 81
Assert.assertEquals(c.getTime(), d);
}
public void testCast() throws Exception {
new TypeUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Assert.assertNull(castToByte(null));
Assert.assertNull(castToShort(null));
Reported by PMD.
Line: 83
public void testCast() throws Exception {
new TypeUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Assert.assertNull(castToByte(null));
Assert.assertNull(castToShort(null));
Assert.assertNull(castToInt(null));
Assert.assertNull(castToLong(null));
Reported by PMD.