The following issues were found
src/test/java/com/alibaba/json/bvt/support/spring/FastJsonpHttpMessageConverter4Test.java
23 issues
Line: 24
import junit.framework.TestCase;
public class FastJsonpHttpMessageConverter4Test extends TestCase {
public void test_1() throws Exception {
FastJsonpHttpMessageConverter4 converter = new FastJsonpHttpMessageConverter4();
Assert.assertNotNull(converter.getFastJsonConfig());
converter.setFastJsonConfig(new FastJsonConfig());
Reported by PMD.
Line: 36
converter.canWrite(VO.class, VO.class, MediaType.APPLICATION_JSON_UTF8);
Method method1 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("supports", Class.class);
method1.setAccessible(true);
method1.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
Reported by PMD.
Line: 37
Method method1 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("supports", Class.class);
method1.setAccessible(true);
method1.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
return null;
Reported by PMD.
Line: 46
}
public InputStream getBody() throws IOException {
return new ByteArrayInputStream("{\"id\":123}".getBytes(Charset.forName("UTF-8")));
}
};
VO vo = (VO) converter.read(VO.class, VO.class, input);
Assert.assertEquals(123, vo.getId());
Reported by PMD.
Line: 51
};
VO vo = (VO) converter.read(VO.class, VO.class, input);
Assert.assertEquals(123, vo.getId());
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
HttpOutputMessage out = new HttpOutputMessage() {
public HttpHeaders getHeaders() {
Reported by PMD.
Line: 71
Method method2 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("readInternal", Class.class,
HttpInputMessage.class);
method2.setAccessible(true);
method2.invoke(converter, VO.class, input);
}
public void test_2() throws Exception {
Reported by PMD.
Line: 72
Method method2 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("readInternal", Class.class,
HttpInputMessage.class);
method2.setAccessible(true);
method2.invoke(converter, VO.class, input);
}
public void test_2() throws Exception {
FastJsonpHttpMessageConverter4 converter = new FastJsonpHttpMessageConverter4();
Reported by PMD.
Line: 75
method2.invoke(converter, VO.class, input);
}
public void test_2() throws Exception {
FastJsonpHttpMessageConverter4 converter = new FastJsonpHttpMessageConverter4();
Assert.assertNotNull(converter.getFastJsonConfig());
converter.setFastJsonConfig(new FastJsonConfig());
Reported by PMD.
Line: 87
converter.canWrite(VO.class, VO.class, MediaType.APPLICATION_JSON_UTF8);
Method method1 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("supports", Class.class);
method1.setAccessible(true);
method1.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
Reported by PMD.
Line: 88
Method method1 = FastJsonpHttpMessageConverter4.class.getDeclaredMethod("supports", Class.class);
method1.setAccessible(true);
method1.invoke(converter, int.class);
HttpInputMessage input = new HttpInputMessage() {
public HttpHeaders getHeaders() {
return null;
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/ByteVector.java
23 issues
Line: 43
/**
* The content of this vector.
*/
public byte[] data;
/**
* Actual number of bytes in this vector.
*/
public int length;
Reported by PMD.
Line: 48
/**
* Actual number of bytes in this vector.
*/
public int length;
/**
* Constructs a new {@link ByteVector ByteVector} with a default initial size.
*/
public ByteVector() {
Reported by PMD.
Line: 96
if (length + 2 > data.length) {
enlarge(2);
}
final byte[] data = this.data;
data[length++] = (byte) b1;
data[length++] = (byte) b2;
this.length = length;
return this;
}
Reported by PMD.
Line: 97
enlarge(2);
}
final byte[] data = this.data;
data[length++] = (byte) b1;
data[length++] = (byte) b2;
this.length = length;
return this;
}
Reported by PMD.
Line: 98
}
final byte[] data = this.data;
data[length++] = (byte) b1;
data[length++] = (byte) b2;
this.length = length;
return this;
}
/**
Reported by PMD.
Line: 115
if (length + 2 > data.length) {
enlarge(2);
}
final byte[] data = this.data;
data[length++] = (byte) (s >>> 8);
data[length++] = (byte) s;
this.length = length;
return this;
}
Reported by PMD.
Line: 116
enlarge(2);
}
final byte[] data = this.data;
data[length++] = (byte) (s >>> 8);
data[length++] = (byte) s;
this.length = length;
return this;
}
Reported by PMD.
Line: 117
}
final byte[] data = this.data;
data[length++] = (byte) (s >>> 8);
data[length++] = (byte) s;
this.length = length;
return this;
}
/**
Reported by PMD.
Line: 135
if (length + 3 > data.length) {
enlarge(3);
}
final byte[] data = this.data;
data[length++] = (byte) b;
data[length++] = (byte) (s >>> 8);
data[length++] = (byte) s;
this.length = length;
return this;
Reported by PMD.
Line: 136
enlarge(3);
}
final byte[] data = this.data;
data[length++] = (byte) b;
data[length++] = (byte) (s >>> 8);
data[length++] = (byte) s;
this.length = length;
return this;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1278.java
23 issues
Line: 16
* Created by kimmking on 20/06/2017.
*/
public class Issue1278 extends TestCase {
public void test_for_issue() throws Exception {
String json1 = "{\"name\":\"name\",\"id\":1}";
String json2 = "{\"user\":\"user\",\"id\":2}";
AlternateNames c1 = JSON.parseObject(json1, AlternateNames.class);
Reported by PMD.
Line: 16
* Created by kimmking on 20/06/2017.
*/
public class Issue1278 extends TestCase {
public void test_for_issue() throws Exception {
String json1 = "{\"name\":\"name\",\"id\":1}";
String json2 = "{\"user\":\"user\",\"id\":2}";
AlternateNames c1 = JSON.parseObject(json1, AlternateNames.class);
Reported by PMD.
Line: 22
String json2 = "{\"user\":\"user\",\"id\":2}";
AlternateNames c1 = JSON.parseObject(json1, AlternateNames.class);
assertEquals("name",c1.name);
assertEquals(1,c1.id);
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
Reported by PMD.
Line: 22
String json2 = "{\"user\":\"user\",\"id\":2}";
AlternateNames c1 = JSON.parseObject(json1, AlternateNames.class);
assertEquals("name",c1.name);
assertEquals(1,c1.id);
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
Reported by PMD.
Line: 23
AlternateNames c1 = JSON.parseObject(json1, AlternateNames.class);
assertEquals("name",c1.name);
assertEquals(1,c1.id);
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
assertEquals(2,c2.id);
Reported by PMD.
Line: 27
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
assertEquals(2,c2.id);
DefaultJSONParser parser = new DefaultJSONParser(json1);
c1 = new AlternateNames();
parser.parseObject(c1);
Reported by PMD.
Line: 27
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
assertEquals(2,c2.id);
DefaultJSONParser parser = new DefaultJSONParser(json1);
c1 = new AlternateNames();
parser.parseObject(c1);
Reported by PMD.
Line: 28
AlternateNames c2 = JSON.parseObject(json2, AlternateNames.class);
assertEquals("user",c2.name);
assertEquals(2,c2.id);
DefaultJSONParser parser = new DefaultJSONParser(json1);
c1 = new AlternateNames();
parser.parseObject(c1);
Reported by PMD.
Line: 34
c1 = new AlternateNames();
parser.parseObject(c1);
assertEquals("name",c1.name);
assertEquals(1,c1.id);
c2 = new AlternateNames();
parser = new DefaultJSONParser(json2);
parser.parseObject(c2);
Reported by PMD.
Line: 35
parser.parseObject(c1);
assertEquals("name",c1.name);
assertEquals(1,c1.id);
c2 = new AlternateNames();
parser = new DefaultJSONParser(json2);
parser.parseObject(c2);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/ThrowableDeserializerTest.java
23 issues
Line: 67
public static class MyException2 extends Exception {
public MyException2() {
throw new RuntimeException();
}
}
}
Reported by PMD.
Line: 11
public class ThrowableDeserializerTest extends TestCase {
public void test_0 () throws Exception {
Assert.assertEquals(Throwable.class, JSON.parseObject("{}", Throwable.class).getClass());
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
Reported by PMD.
Line: 12
public class ThrowableDeserializerTest extends TestCase {
public void test_0 () throws Exception {
Assert.assertEquals(Throwable.class, JSON.parseObject("{}", Throwable.class).getClass());
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
Reported by PMD.
Line: 13
public class ThrowableDeserializerTest extends TestCase {
public void test_0 () throws Exception {
Assert.assertEquals(Throwable.class, JSON.parseObject("{}", Throwable.class).getClass());
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
Reported by PMD.
Line: 14
public void test_0 () throws Exception {
Assert.assertEquals(Throwable.class, JSON.parseObject("{}", Throwable.class).getClass());
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
public void test_error() throws Exception {
Reported by PMD.
Line: 15
Assert.assertEquals(Throwable.class, JSON.parseObject("{}", Throwable.class).getClass());
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
public void test_error() throws Exception {
JSONException error = null;
Reported by PMD.
Line: 16
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
public void test_error() throws Exception {
JSONException error = null;
try {
Reported by PMD.
Line: 16
Assert.assertEquals(Throwable.class, JSON.parseObject("{,,,}", Throwable.class).getClass());
Assert.assertEquals(java.lang.RuntimeException.class, JSON.parseObject("{\"@type\":\"java.lang.RuntimeException\"}", Throwable.class).getClass());
Assert.assertEquals(null, JSON.parseObject("{\"message\":null}", Throwable.class).getMessage());
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
public void test_error() throws Exception {
JSONException error = null;
try {
Reported by PMD.
Line: 19
Assert.assertEquals(Exception.class, JSON.parseObject("{\"cause\":{}}", Throwable.class).getCause().getClass());
}
public void test_error() throws Exception {
JSONException error = null;
try {
JSON.parseObject("{\"@type\":33}", Throwable.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 29
Assert.assertNotNull(error);
}
public void test_error1() throws Exception {
JSONException error = null;
try {
Assert.assertEquals(null, JSON.parseObject("{\"message\":33}", Throwable.class).getMessage());
} catch (JSONException ex) {
error = ex;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_rd.java
23 issues
Line: 10
import java.util.concurrent.TimeUnit;
public class Bug_for_rd extends TestCase {
public void test_for_issue() throws Exception {
String json = "{ \"sitePayId\": \"2019071889031100000152604119889\", \"extendInfo\": \"{\\\"saveAsset\\\":\\\"false\\\",\\\"acquirementId\\\":\\\"20190718194010800100177150204979354\\\",\\\"orderTerminalType\\\":\\\"WEB\\\",\\\"acqSiteUserId\\\":\\\"2177220032166157\\\",\\\"siteReqBizId\\\":\\\"111023437\\\",\\\"msisdn\\\":\\\"01966114400\\\",\\\"originalMerchantOrderId\\\":\\\"602109378031994\\\"}\", \"netPayId\": \"2019071819039101720000454701\", \"resultInfo\": { \"resultCode\": \"SUCCESS\", \"resultCodeId\": \"00000000\", \"resultMsg\": \"Success\", \"resultStatus\": \"S\" } }";
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{ \"sitePayId\": \"2019071889031100000152604119889\", \"extendInfo\": \"{\\\"saveAsset\\\":\\\"false\\\",\\\"acquirementId\\\":\\\"20190718194010800100177150204979354\\\",\\\"orderTerminalType\\\":\\\"WEB\\\",\\\"acqSiteUserId\\\":\\\"2177220032166157\\\",\\\"siteReqBizId\\\":\\\"111023437\\\",\\\"msisdn\\\":\\\"01966114400\\\",\\\"originalMerchantOrderId\\\":\\\"602109378031994\\\"}\", \"netPayId\": \"2019071819039101720000454701\", \"resultInfo\": { \"resultCode\": \"SUCCESS\", \"resultCodeId\": \"00000000\", \"resultMsg\": \"Success\", \"resultStatus\": \"S\" } }";
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{ \"sitePayId\": \"2019071889031100000152604119889\", \"extendInfo\": \"{\\\"saveAsset\\\":\\\"false\\\",\\\"acquirementId\\\":\\\"20190718194010800100177150204979354\\\",\\\"orderTerminalType\\\":\\\"WEB\\\",\\\"acqSiteUserId\\\":\\\"2177220032166157\\\",\\\"siteReqBizId\\\":\\\"111023437\\\",\\\"msisdn\\\":\\\"01966114400\\\",\\\"originalMerchantOrderId\\\":\\\"602109378031994\\\"}\", \"netPayId\": \"2019071819039101720000454701\", \"resultInfo\": { \"resultCode\": \"SUCCESS\", \"resultCodeId\": \"00000000\", \"resultMsg\": \"Success\", \"resultStatus\": \"S\" } }";
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
Reported by PMD.
Line: 15
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
String json = "{\"unit\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
Reported by PMD.
Line: 15
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
String json = "{\"unit\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
Reported by PMD.
Line: 15
PayResponse object = JSON.parseObject(json, PayResponse.class);
String extendInfo = object.getExtendInfo();
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
String json = "{\"unit\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
Reported by PMD.
Line: 18
assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
}
public void test_for_issue_1() throws Exception {
String json = "{\"unit\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
assertEquals(TimeUnit.MINUTES, v.unit);
}
Reported by PMD.
Line: 21
public void test_for_issue_1() throws Exception {
String json = "{\"unit\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
assertEquals(TimeUnit.MINUTES, v.unit);
}
public void test_for_issue_2() throws Exception {
String json = "{\"sitePayId\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
Reported by PMD.
Line: 24
assertEquals(TimeUnit.MINUTES, v.unit);
}
public void test_for_issue_2() throws Exception {
String json = "{\"sitePayId\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
assertEquals("MINUTES", v.sitePayId);
}
Reported by PMD.
Line: 27
public void test_for_issue_2() throws Exception {
String json = "{\"sitePayId\": \"MINUTES\"}";
V1 v = JSON.parseObject(json, V1.class);
assertEquals("MINUTES", v.sitePayId);
}
public void test_for_issue_3() throws Exception {
String json = "{\"sitePayId\": \"MINUTES\\\"A\"}";
V1 v = JSON.parseObject(json, V1.class);
Reported by PMD.
src/test/java/com/alibaba/json/test/a/Alipay1206.java
23 issues
Line: 44
JSONObject constraintOptionalRecordMap = conditionConstraint.getJSONObject(0).getJSONObject("constraintOptionalRecordMap");
assertNotNull(constraintOptionalRecordMap);
System.out.println(constraintOptionalRecordMap);
}
}
Reported by PMD.
Line: 15
* Created by wenshao on 06/12/2016.
*/
public class Alipay1206 extends TestCase {
public void test_for_alipay() throws Exception {
File file = new File("/Users/wenshao/Downloads/x.txt");
String text = FileUtils.readFileToString(file);
JSONObject root = JSON.parseObject(text);
JSONObject resultObj = root.getJSONObject("resultObj");
Reported by PMD.
Line: 15
* Created by wenshao on 06/12/2016.
*/
public class Alipay1206 extends TestCase {
public void test_for_alipay() throws Exception {
File file = new File("/Users/wenshao/Downloads/x.txt");
String text = FileUtils.readFileToString(file);
JSONObject root = JSON.parseObject(text);
JSONObject resultObj = root.getJSONObject("resultObj");
Reported by PMD.
Line: 20
String text = FileUtils.readFileToString(file);
JSONObject root = JSON.parseObject(text);
JSONObject resultObj = root.getJSONObject("resultObj");
assertNotNull(resultObj);
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
Reported by PMD.
Line: 21
JSONObject root = JSON.parseObject(text);
JSONObject resultObj = root.getJSONObject("resultObj");
assertNotNull(resultObj);
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
Reported by PMD.
Line: 23
JSONObject resultObj = root.getJSONObject("resultObj");
assertNotNull(resultObj);
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
assertNotNull(conditionGroup);
Reported by PMD.
Line: 24
assertNotNull(resultObj);
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
assertNotNull(conditionGroup);
JSONArray recordList = conditionGroup.getJSONArray("recordList");
Reported by PMD.
Line: 26
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
assertNotNull(conditionGroup);
JSONArray recordList = conditionGroup.getJSONArray("recordList");
assertNotNull(recordList);
Reported by PMD.
Line: 26
JSONArray conditionGroupItemList = resultObj.getJSONArray("conditionGroupItemList");
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
assertNotNull(conditionGroup);
JSONArray recordList = conditionGroup.getJSONArray("recordList");
assertNotNull(recordList);
Reported by PMD.
Line: 27
assertNotNull(conditionGroupItemList);
JSONObject conditionGroup = conditionGroupItemList.getJSONObject(0).getJSONObject("conditionGroup");
assertNotNull(conditionGroup);
JSONArray recordList = conditionGroup.getJSONArray("recordList");
assertNotNull(recordList);
JSONArray conditionItemList = recordList.getJSONObject(0).getJSONArray("conditionItemList");
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/DefaultFieldDeserializer.java
23 issues
Line: 20
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.FieldInfo;
public class DefaultFieldDeserializer extends FieldDeserializer {
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
Reported by PMD.
Line: 20
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.FieldInfo;
public class DefaultFieldDeserializer extends FieldDeserializer {
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
Reported by PMD.
Line: 22
public class DefaultFieldDeserializer extends FieldDeserializer {
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
JSONField annotation = fieldInfo.getAnnotation();
Reported by PMD.
Line: 23
public class DefaultFieldDeserializer extends FieldDeserializer {
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
JSONField annotation = fieldInfo.getAnnotation();
if (annotation != null) {
Reported by PMD.
Line: 23
public class DefaultFieldDeserializer extends FieldDeserializer {
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
JSONField annotation = fieldInfo.getAnnotation();
if (annotation != null) {
Reported by PMD.
Line: 25
protected ObjectDeserializer fieldValueDeserilizer;
protected boolean customDeserilizer = false;
public DefaultFieldDeserializer(ParserConfig config, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
JSONField annotation = fieldInfo.getAnnotation();
if (annotation != null) {
Class<?> deserializeUsing = annotation.deserializeUsing();
customDeserilizer = deserializeUsing != null && deserializeUsing != Void.class;
Reported by PMD.
Line: 37
public ObjectDeserializer getFieldValueDeserilizer(ParserConfig config) {
if (fieldValueDeserilizer == null) {
JSONField annotation = fieldInfo.getAnnotation();
if (annotation != null && annotation.deserializeUsing() != Void.class) {
Class<?> deserializeUsing = annotation.deserializeUsing();
try {
fieldValueDeserilizer = (ObjectDeserializer) deserializeUsing.newInstance();
} catch (Exception ex) {
throw new JSONException("create deserializeUsing ObjectDeserializer error", ex);
Reported by PMD.
Line: 38
if (fieldValueDeserilizer == null) {
JSONField annotation = fieldInfo.getAnnotation();
if (annotation != null && annotation.deserializeUsing() != Void.class) {
Class<?> deserializeUsing = annotation.deserializeUsing();
try {
fieldValueDeserilizer = (ObjectDeserializer) deserializeUsing.newInstance();
} catch (Exception ex) {
throw new JSONException("create deserializeUsing ObjectDeserializer error", ex);
}
Reported by PMD.
Line: 40
if (annotation != null && annotation.deserializeUsing() != Void.class) {
Class<?> deserializeUsing = annotation.deserializeUsing();
try {
fieldValueDeserilizer = (ObjectDeserializer) deserializeUsing.newInstance();
} catch (Exception ex) {
throw new JSONException("create deserializeUsing ObjectDeserializer error", ex);
}
} else {
fieldValueDeserilizer = config.getDeserializer(fieldInfo.fieldClass, fieldInfo.fieldType);
Reported by PMD.
Line: 41
Class<?> deserializeUsing = annotation.deserializeUsing();
try {
fieldValueDeserilizer = (ObjectDeserializer) deserializeUsing.newInstance();
} catch (Exception ex) {
throw new JSONException("create deserializeUsing ObjectDeserializer error", ex);
}
} else {
fieldValueDeserilizer = config.getDeserializer(fieldInfo.fieldClass, fieldInfo.fieldType);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayTest.java
22 issues
Line: 18
public class BeanToArrayTest extends TestCase {
public void test_beanToArray_parse() throws Exception {
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Reported by PMD.
Line: 22
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
Reported by PMD.
Line: 23
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 23
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilter_long_field.java
22 issues
Line: 15
public class PropertyFilter_long_field extends TestCase {
public void test_0() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
Reported by PMD.
Line: 25
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 34
Assert.assertEquals("{}", text);
}
public void test_1() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("id".equals(name)) {
Assert.assertTrue(value instanceof Long);
Reported by PMD.
Line: 48
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 57
Assert.assertEquals("{\"id\":0}", text);
}
public void test_2() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 61
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
}
return false;
}
};
Reported by PMD.
Line: 70
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
a.name = "chennp2008";
serializer.write(a);
Reported by PMD.
Line: 80
Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
public void test_3() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 93
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "chennp2008");
serializer.write(map);
Reported by PMD.
Line: 103
Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
public void test_4() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return false;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2754.java
22 issues
Line: 11
import java.util.TimeZone;
public class Issue2754 extends TestCase {
public void test_for_issue0() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
Reported by PMD.
Line: 15
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
Reported by PMD.
Line: 15
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
Reported by PMD.
Line: 17
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 17
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 20
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
Reported by PMD.
Line: 24
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
Reported by PMD.
Line: 26
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 26
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 29
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Kathmandu"));
Reported by PMD.