The following issues were found
src/main/java/com/alibaba/fastjson/serializer/AnnotationSerializer.java
27 issues
Line: 17
/**
* Created by wenshao on 10/05/2017.
*/
public class AnnotationSerializer implements ObjectSerializer {
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
Reported by PMD.
Line: 17
/**
* Created by wenshao on 10/05/2017.
*/
public class AnnotationSerializer implements ObjectSerializer {
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
Reported by PMD.
Line: 18
* Created by wenshao on 10/05/2017.
*/
public class AnnotationSerializer implements ObjectSerializer {
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
public static AnnotationSerializer instance = new AnnotationSerializer();
Reported by PMD.
Line: 19
*/
public class AnnotationSerializer implements ObjectSerializer {
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
public static AnnotationSerializer instance = new AnnotationSerializer();
Reported by PMD.
Line: 20
public class AnnotationSerializer implements ObjectSerializer {
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Reported by PMD.
Line: 21
private static volatile Class sun_AnnotationType = null;
private static volatile boolean sun_AnnotationType_error = false;
private static volatile Method sun_AnnotationType_getInstance = null;
private static volatile Method sun_AnnotationType_members = null;
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Reported by PMD.
Line: 25
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Class[] interfaces = objClass.getInterfaces();
if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
Class annotationClass = interfaces[0];
Reported by PMD.
Line: 25
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Class[] interfaces = objClass.getInterfaces();
if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
Class annotationClass = interfaces[0];
Reported by PMD.
Line: 25
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Class[] interfaces = objClass.getInterfaces();
if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
Class annotationClass = interfaces[0];
Reported by PMD.
Line: 25
public static AnnotationSerializer instance = new AnnotationSerializer();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Class[] interfaces = objClass.getInterfaces();
if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
Class annotationClass = interfaces[0];
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_singQuoteString.java
27 issues
Line: 14
public class JSONScannerTest_singQuoteString extends TestCase {
public void test_string() throws Exception {
{
JSONScanner lexer = new JSONScanner("\'中国\'");
lexer.config(Feature.AllowSingleQuotes, true);
lexer.nextToken();
Assert.assertEquals("中国", lexer.stringVal());
Reported by PMD.
Line: 34
Assert.assertEquals("中国\tV5", lexer.stringVal());
}
StringBuilder buf = new StringBuilder();
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
Reported by PMD.
Line: 36
StringBuilder buf = new StringBuilder();
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 36
StringBuilder buf = new StringBuilder();
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 37
StringBuilder buf = new StringBuilder();
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 37
StringBuilder buf = new StringBuilder();
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 38
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
Reported by PMD.
Line: 38
buf.append('\'');
buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
buf.append('\'');
buf.append('\u2001');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
Reported by PMD.
Line: 43
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
lexer.config(Feature.AllowSingleQuotes, true);
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
Reported by PMD.
Line: 43
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
lexer.config(Feature.AllowSingleQuotes, true);
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest3.java
27 issues
Line: 12
public class JSONObjectTest3 extends TestCase {
public void test_0() throws Exception {
String text = "{value:'123',big:false}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals("123", bean.getValue());
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
Reported by PMD.
Line: 13
public class JSONObjectTest3 extends TestCase {
public void test_0() throws Exception {
String text = "{value:'123',big:false}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals("123", bean.getValue());
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
Reported by PMD.
Line: 15
public void test_0() throws Exception {
String text = "{value:'123',big:false}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals("123", bean.getValue());
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
Reported by PMD.
Line: 16
String text = "{value:'123',big:false}";
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals("123", bean.getValue());
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
Reported by PMD.
Line: 17
Bean bean = JSON.parseObject(text, Bean.class);
Assert.assertEquals("123", bean.getValue());
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
bean.setID(567);
Reported by PMD.
Line: 19
Assert.assertEquals(false, bean.isBig());
Assert.assertEquals(123, bean.getIntValue());
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
bean.setID(567);
Assert.assertEquals(567, bean.getID());
Reported by PMD.
Line: 20
Assert.assertEquals(123, bean.getIntValue());
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
bean.setID(567);
Assert.assertEquals(567, bean.getID());
}
Reported by PMD.
Line: 22
bean.setBig(true);
Assert.assertEquals(true, bean.isBig());
bean.setID(567);
Assert.assertEquals(567, bean.getID());
}
public void test_error_0() throws Exception {
Reported by PMD.
Line: 23
Assert.assertEquals(true, bean.isBig());
bean.setID(567);
Assert.assertEquals(567, bean.getID());
}
public void test_error_0() throws Exception {
String text = "{value:'123',big:false}";
Reported by PMD.
Line: 27
}
public void test_error_0() throws Exception {
String text = "{value:'123',big:false}";
Bean bean = JSON.parseObject(text, Bean.class);
JSONException error = null;
try {
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/Type.java
27 issues
Line: 38
* @author Eric Bruneton
* @author Chris Nokleberg
*/
public class Type {
/**
* The <tt>void</tt> type.
*/
public static final Type VOID_TYPE = new Type(0, null, ('V' << 24) | (5 << 16) | (0 << 8) | 0, 1);
Reported by PMD.
Line: 38
* @author Eric Bruneton
* @author Chris Nokleberg
*/
public class Type {
/**
* The <tt>void</tt> type.
*/
public static final Type VOID_TYPE = new Type(0, null, ('V' << 24) | (5 << 16) | (0 << 8) | 0, 1);
Reported by PMD.
Line: 91
/**
* The sort of this Java type.
*/
protected final int sort;
/**
* A buffer containing the internal name of this Java type. This field is only used for reference types.
*/
private final char[] buf;
Reported by PMD.
Line: 96
/**
* A buffer containing the internal name of this Java type. This field is only used for reference types.
*/
private final char[] buf;
/**
* The offset of the internal name of this Java type in {@link #buf buf} or, for primitive types, the size,
* descriptor and getOpcode offsets for this type (byte 0 contains the size, byte 1 the descriptor, byte 2 the
* offset for IALOAD or IASTORE, byte 3 the offset for all other instructions).
Reported by PMD.
Line: 103
* descriptor and getOpcode offsets for this type (byte 0 contains the size, byte 1 the descriptor, byte 2 the
* offset for IALOAD or IASTORE, byte 3 the offset for all other instructions).
*/
private final int off;
/**
* The length of the internal name of this Java type.
*/
private final int len;
Reported by PMD.
Line: 108
/**
* The length of the internal name of this Java type.
*/
private final int len;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
Reported by PMD.
Line: 131
return getType(typeDescriptor.toCharArray(), 0);
}
public static int getArgumentsAndReturnSizes(final String desc) {
int n = 1;
int c = 1;
while (true) {
char car = desc.charAt(c++);
if (car == ')') {
Reported by PMD.
Line: 136
int c = 1;
while (true) {
char car = desc.charAt(c++);
if (car == ')') {
car = desc.charAt(c);
return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
} else if (car == 'L') {
while (desc.charAt(c++) != ';') {
}
Reported by PMD.
Line: 139
if (car == ')') {
car = desc.charAt(c);
return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
} else if (car == 'L') {
while (desc.charAt(c++) != ';') {
}
n += 1;
// } else if (car == '[') {
// while ((car = desc.charAt(c)) == '[') {
Reported by PMD.
Line: 140
car = desc.charAt(c);
return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
} else if (car == 'L') {
while (desc.charAt(c++) != ';') {
}
n += 1;
// } else if (car == '[') {
// while ((car = desc.charAt(c)) == '[') {
// ++c;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_16.java
27 issues
Line: 9
import com.alibaba.fastjson.JSON;
public class JSONLexerTest_16 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
}
Reported by PMD.
Line: 11
public class JSONLexerTest_16 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
}
public void test_1() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
Reported by PMD.
Line: 12
public class JSONLexerTest_16 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
}
public void test_1() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
}
Reported by PMD.
Line: 15
Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
}
public void test_1() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
}
public void test_2() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
Reported by PMD.
Line: 16
}
public void test_1() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
}
public void test_2() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
}
Reported by PMD.
Line: 19
Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
}
public void test_2() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
}
public void test_3() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
Reported by PMD.
Line: 20
}
public void test_2() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
}
public void test_3() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
}
Reported by PMD.
Line: 23
Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
}
public void test_3() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
}
public void test_4() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));
Reported by PMD.
Line: 24
}
public void test_3() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
}
public void test_4() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));
}
Reported by PMD.
Line: 27
Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
}
public void test_4() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));
}
public void test_5() throws Exception {
Assert.assertEquals(123, JSON.parseObject("{\"\\5\":123}").get("\5"));
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/MethodWriter.java
27 issues
Line: 36
* @author Eric Bruneton
* @author Eugene Kuleshov
*/
public class MethodWriter implements MethodVisitor {
/**
* Next method writer (see {@link ClassWriter#firstMethod firstMethod}).
*/
MethodWriter next;
Reported by PMD.
Line: 41
/**
* Next method writer (see {@link ClassWriter#firstMethod firstMethod}).
*/
MethodWriter next;
/**
* The class writer to which this method must be added.
*/
final ClassWriter cw;
Reported by PMD.
Line: 46
/**
* The class writer to which this method must be added.
*/
final ClassWriter cw;
/**
* Access flags of this method.
*/
private int access;
Reported by PMD.
Line: 51
/**
* Access flags of this method.
*/
private int access;
/**
* The index of the constant pool item that contains the name of this method.
*/
private final int name;
Reported by PMD.
Line: 51
/**
* Access flags of this method.
*/
private int access;
/**
* The index of the constant pool item that contains the name of this method.
*/
private final int name;
Reported by PMD.
Line: 56
/**
* The index of the constant pool item that contains the name of this method.
*/
private final int name;
/**
* The index of the constant pool item that contains the descriptor of this method.
*/
private final int desc;
Reported by PMD.
Line: 61
/**
* The index of the constant pool item that contains the descriptor of this method.
*/
private final int desc;
/**
* Number of exceptions that can be thrown by this method.
*/
int exceptionCount;
Reported by PMD.
Line: 66
/**
* Number of exceptions that can be thrown by this method.
*/
int exceptionCount;
/**
* The exceptions that can be thrown by this method. More precisely, this array contains the indexes of the constant
* pool items that contain the internal names of these exception classes.
*/
Reported by PMD.
Line: 72
* The exceptions that can be thrown by this method. More precisely, this array contains the indexes of the constant
* pool items that contain the internal names of these exception classes.
*/
int[] exceptions;
/**
* The bytecode of this method.
*/
private ByteVector code = new ByteVector();
Reported by PMD.
Line: 77
/**
* The bytecode of this method.
*/
private ByteVector code = new ByteVector();
/**
* Maximum stack size of this method.
*/
private int maxStack;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/FastJsonHttpMessageConverterTest.java
27 issues
Line: 29
public class FastJsonHttpMessageConverterTest extends TestCase {
@SuppressWarnings("deprecation")
public void test_read() throws Exception {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converter.setCharset(Charset.forName("UTF-8"));
Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());
Reported by PMD.
Line: 32
@SuppressWarnings("deprecation")
public void test_read() throws Exception {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converter.setCharset(Charset.forName("UTF-8"));
Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());
converter.setFeatures(SerializerFeature.BrowserCompatible);
Assert.assertEquals(1, converter.getFeatures().length);
Assert.assertEquals(SerializerFeature.BrowserCompatible,
Reported by PMD.
Line: 36
Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());
converter.setFeatures(SerializerFeature.BrowserCompatible);
Assert.assertEquals(1, converter.getFeatures().length);
Assert.assertEquals(SerializerFeature.BrowserCompatible,
converter.getFeatures()[0]);
Assert.assertNull(converter.getDateFormat());
converter.setDateFormat("yyyyMMdd");
Reported by PMD.
Line: 44
converter.setDateFormat("yyyyMMdd");
converter.setFilters(serializeFilter);
Assert.assertEquals(1, converter.getFilters().length);
Assert.assertEquals(serializeFilter, converter.getFilters()[0]);
converter.addSerializeFilter(serializeFilter);
Assert.assertEquals(2, converter.getFilters().length);
converter.addSerializeFilter(null);
Reported by PMD.
Line: 48
Assert.assertEquals(serializeFilter, converter.getFilters()[0]);
converter.addSerializeFilter(serializeFilter);
Assert.assertEquals(2, converter.getFilters().length);
converter.addSerializeFilter(null);
converter.setSupportedMediaTypes(Arrays
.asList(new MediaType[] { MediaType.APPLICATION_JSON_UTF8 }));
Assert.assertEquals(1, converter.getSupportedMediaTypes().size());
Reported by PMD.
Line: 53
converter.setSupportedMediaTypes(Arrays
.asList(new MediaType[] { MediaType.APPLICATION_JSON_UTF8 }));
Assert.assertEquals(1, converter.getSupportedMediaTypes().size());
Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
"supports", Class.class);
method.setAccessible(true);
method.invoke(converter, int.class);
Reported by PMD.
Line: 57
Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
"supports", Class.class);
method.setAccessible(true);
method.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
Reported by PMD.
Line: 58
Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
"supports", Class.class);
method.setAccessible(true);
method.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
// TODO Auto-generated method stub
Reported by PMD.
Line: 74
};
VO vo = (VO) converter.read(VO.class, input);
Assert.assertEquals(123, vo.getId());
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
HttpOutputMessage out = new HttpOutputMessage() {
public HttpHeaders getHeaders() {
Reported by PMD.
Line: 93
Assert.assertEquals("{\"id\":\"123\"}", new String(bytes, "UTF-8"));
}
public void test_1() throws Exception {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
Assert.assertNotNull(converter.getFastJsonConfig());
converter.setFastJsonConfig(new FastJsonConfig());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2241.java
27 issues
Line: 15
import java.util.TimeZone;
public class Issue2241 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 20
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String text = "{\"createTime\":1548166745}";
Order o = JSON.parseObject(text, Order.class);
assertEquals(1548166745000L, o.createTime.getTime());
Reported by PMD.
Line: 20
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String text = "{\"createTime\":1548166745}";
Order o = JSON.parseObject(text, Order.class);
assertEquals(1548166745000L, o.createTime.getTime());
Reported by PMD.
Line: 21
}
public void test_for_issue() throws Exception {
String text = "{\"createTime\":1548166745}";
Order o = JSON.parseObject(text, Order.class);
assertEquals(1548166745000L, o.createTime.getTime());
String json = JSON.toJSONString(o);
Reported by PMD.
Line: 24
String text = "{\"createTime\":1548166745}";
Order o = JSON.parseObject(text, Order.class);
assertEquals(1548166745000L, o.createTime.getTime());
String json = JSON.toJSONString(o);
assertEquals("{\"createTime\":1548166745}", json);
}
Reported by PMD.
Line: 24
String text = "{\"createTime\":1548166745}";
Order o = JSON.parseObject(text, Order.class);
assertEquals(1548166745000L, o.createTime.getTime());
String json = JSON.toJSONString(o);
assertEquals("{\"createTime\":1548166745}", json);
}
Reported by PMD.
Line: 27
assertEquals(1548166745000L, o.createTime.getTime());
String json = JSON.toJSONString(o);
assertEquals("{\"createTime\":1548166745}", json);
}
public void test_for_issue2() throws Exception {
String text = "{\"createTime\":1548166745}";
Reported by PMD.
Line: 30
assertEquals("{\"createTime\":1548166745}", json);
}
public void test_for_issue2() throws Exception {
String text = "{\"createTime\":1548166745}";
Order2 o = JSON.parseObject(text, Order2.class);
assertEquals(1548166745000L, o.createTime.getTimeInMillis());
Reported by PMD.
Line: 30
assertEquals("{\"createTime\":1548166745}", json);
}
public void test_for_issue2() throws Exception {
String text = "{\"createTime\":1548166745}";
Order2 o = JSON.parseObject(text, Order2.class);
assertEquals(1548166745000L, o.createTime.getTimeInMillis());
Reported by PMD.
Line: 34
String text = "{\"createTime\":1548166745}";
Order2 o = JSON.parseObject(text, Order2.class);
assertEquals(1548166745000L, o.createTime.getTimeInMillis());
String json = JSON.toJSONString(o);
assertEquals("{\"createTime\":1548166745}", json);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_127_for_qiuyan81.java
27 issues
Line: 10
import junit.framework.TestCase;
public class Bug_127_for_qiuyan81 extends TestCase {
public void test_parserUndefined() {
String jsonString = "{PayStatus:0,RunEmpId:undefined}";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
Reported by PMD.
Line: 12
public class Bug_127_for_qiuyan81 extends TestCase {
public void test_parserUndefined() {
String jsonString = "{PayStatus:0,RunEmpId:undefined}";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
Reported by PMD.
Line: 15
public void test_parserUndefined() {
String jsonString = "{PayStatus:0,RunEmpId:undefined}";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
public void test_parserUndefined_space() {
String jsonString = "{PayStatus:0,RunEmpId:undefined }";
Object json = JSON.parse(jsonString);
Reported by PMD.
Line: 15
public void test_parserUndefined() {
String jsonString = "{PayStatus:0,RunEmpId:undefined}";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
public void test_parserUndefined_space() {
String jsonString = "{PayStatus:0,RunEmpId:undefined }";
Object json = JSON.parse(jsonString);
Reported by PMD.
Line: 18
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
public void test_parserUndefined_space() {
String jsonString = "{PayStatus:0,RunEmpId:undefined }";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
Reported by PMD.
Line: 21
public void test_parserUndefined_space() {
String jsonString = "{PayStatus:0,RunEmpId:undefined }";
Object json = JSON.parse(jsonString);
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
public void test_parserUndefined_comma() {
String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
JSONObject json = (JSONObject) JSON.parse(jsonString);
Reported by PMD.
Line: 24
Assert.assertEquals("{\"PayStatus\":0}", json.toString());
}
public void test_parserUndefined_comma() {
String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
JSONObject json = (JSONObject) JSON.parse(jsonString);
Assert.assertEquals(1001, json.get("ext"));
Assert.assertEquals(0, json.get("PayStatus"));
Assert.assertEquals(3, json.size());
Reported by PMD.
Line: 27
public void test_parserUndefined_comma() {
String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
JSONObject json = (JSONObject) JSON.parse(jsonString);
Assert.assertEquals(1001, json.get("ext"));
Assert.assertEquals(0, json.get("PayStatus"));
Assert.assertEquals(3, json.size());
}
public void test_parserUndefined_array() {
Reported by PMD.
Line: 28
String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
JSONObject json = (JSONObject) JSON.parse(jsonString);
Assert.assertEquals(1001, json.get("ext"));
Assert.assertEquals(0, json.get("PayStatus"));
Assert.assertEquals(3, json.size());
}
public void test_parserUndefined_array() {
String jsonString = "[0,undefined]";
Reported by PMD.
Line: 29
JSONObject json = (JSONObject) JSON.parse(jsonString);
Assert.assertEquals(1001, json.get("ext"));
Assert.assertEquals(0, json.get("PayStatus"));
Assert.assertEquals(3, json.size());
}
public void test_parserUndefined_array() {
String jsonString = "[0,undefined]";
Object json = JSON.parse(jsonString);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/StackTraceElementDeserializerTest.java
27 issues
Line: 9
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
public class StackTraceElementDeserializerTest extends TestCase {
public void test_stack() throws Exception {
Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
Reported by PMD.
Line: 11
public class StackTraceElementDeserializerTest extends TestCase {
public void test_stack() throws Exception {
Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
Reported by PMD.
Line: 14
public void test_stack() throws Exception {
Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
StackTraceElement.class).getFileName());
Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
Reported by PMD.
Line: 15
Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
StackTraceElement.class).getFileName());
Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
}
Reported by PMD.
Line: 16
Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
StackTraceElement.class).getFileName());
Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
}
Reported by PMD.
Line: 22
Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
}
public void test_stack_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("{}", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 32
Assert.assertNotNull(error);
}
public void test_stack_error_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("[]", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 42
Assert.assertNotNull(error);
}
public void test_stack_error_2() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"className\":null,\"methodName\":null,\"fileName\":null,\"lineNumber\":null,\"@type\":\"xxx\"}", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 52
Assert.assertNotNull(error);
}
public void test_stack_error_3() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"@type\":int}", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 62
Assert.assertNotNull(error);
}
public void test_stack_error_4() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"xxx\":33}", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.